Skip to content

Commit

Permalink
Auto merge of #29766 - oli-obk:impl_item, r=nikomatsakis
Browse files Browse the repository at this point in the history
[breaking change]

I'm not sure if those renames are ok. [TokenType::Tt* to TokenType::*](#29582) was obvious, but for all those Item-enums it's less obvious to me what the right way forward is due to the underscore.
  • Loading branch information
bors committed Nov 17, 2015
2 parents 8809a33 + d09220d commit b31cc64
Show file tree
Hide file tree
Showing 41 changed files with 150 additions and 154 deletions.
2 changes: 1 addition & 1 deletion src/librustc/front/map/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl<'a> FnLikeNode<'a> {
},
map::NodeImplItem(ii) => {
match ii.node {
ast::MethodImplItem(ref sig, ref body) => {
ast::ImplItemKind::Method(ref sig, ref body) => {
method(ii.id, ii.name, sig, Some(ii.vis), body, ii.span)
}
_ => {
Expand Down
7 changes: 3 additions & 4 deletions src/librustc/front/map/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {

fn visit_impl_item(&mut self, ii: &'ast ImplItem) {
let def_data = match ii.node {
MethodImplItem(..) | ConstImplItem(..) => DefPathData::Value(ii.name),
TypeImplItem(..) => DefPathData::Type(ii.name),
ImplItemKind::Method(..) | ImplItemKind::Const(..) => DefPathData::Value(ii.name),
ImplItemKind::Type(..) => DefPathData::Type(ii.name),
};

self.insert_def(ii.id, NodeImplItem(ii), def_data);
Expand All @@ -234,7 +234,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
self.parent_node = ii.id;

match ii.node {
ConstImplItem(_, ref expr) => {
ImplItemKind::Const(_, ref expr) => {
self.create_def(expr.id, DefPathData::Initializer);
}
_ => { }
Expand Down Expand Up @@ -313,4 +313,3 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
self.create_def(macro_def.id, DefPathData::MacroDef(macro_def.name));
}
}

6 changes: 3 additions & 3 deletions src/librustc/front/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -937,18 +937,18 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
}
Some(NodeImplItem(ii)) => {
match ii.node {
ConstImplItem(..) => {
ImplItemKind::Const(..) => {
format!("assoc const {} in {}{}",
ii.name,
map.path_to_string(id),
id_str)
}
MethodImplItem(..) => {
ImplItemKind::Method(..) => {
format!("method {} in {}{}",
ii.name,
map.path_to_string(id), id_str)
}
TypeImplItem(_) => {
ImplItemKind::Type(_) => {
format!("assoc type {} in {}{}",
ii.name,
map.path_to_string(id),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
let elem = ast_map::PathName(m.name);
encode_path(rbml_w, impl_path.chain(Some(elem)));
if let Some(impl_item) = impl_item_opt {
if let hir::MethodImplItem(ref sig, _) = impl_item.node {
if let hir::ImplItemKind::Method(ref sig, _) = impl_item.node {
encode_attributes(rbml_w, &impl_item.attrs);
let scheme = ecx.tcx.lookup_item_type(m.def_id);
let any_types = !scheme.generics.types.is_empty();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {

fn visit_impl_item(&mut self, i: &'v hir::ImplItem) {
match i.node {
hir::ConstImplItem(_, ref expr) => {
hir::ImplItemKind::Const(_, ref expr) => {
self.global_expr(Mode::Const, &*expr);
}
_ => self.with_mode(Mode::Var, |v| visit::walk_impl_item(v, i)),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_static_recursion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> {

fn visit_impl_item(&mut self, ii: &'ast hir::ImplItem) {
match ii.node {
hir::ConstImplItem(..) => {
hir::ImplItemKind::Const(..) => {
let mut recursion_visitor =
CheckItemRecursionVisitor::new(self, &ii.span);
recursion_visitor.visit_impl_item(ii);
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
_ => None
},
Some(ast_map::NodeImplItem(ii)) => match ii.node {
hir::ConstImplItem(_, ref expr) => {
hir::ImplItemKind::Const(_, ref expr) => {
Some(&*expr)
}
_ => None
Expand Down Expand Up @@ -171,7 +171,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
_ => None
},
csearch::FoundAst::Found(&InlinedItem::ImplItem(_, ref ii)) => match ii.node {
hir::ConstImplItem(_, ref expr) => Some(expr.id),
hir::ImplItemKind::Const(_, ref expr) => Some(expr.id),
_ => None
},
_ => None
Expand Down Expand Up @@ -996,7 +996,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
},
ty::ImplContainer(_) => match tcx.map.find(node_id) {
Some(ast_map::NodeImplItem(ii)) => match ii.node {
hir::ConstImplItem(ref ty, ref expr) => {
hir::ImplItemKind::Const(ref ty, ref expr) => {
(Some(&**expr), Some(&**ty))
}
_ => (None, None)
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/middle/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,14 @@ impl<'v> Visitor<'v> for LifeSeeder {
hir::ItemImpl(_, _, _, ref opt_trait, _, ref impl_items) => {
for impl_item in impl_items {
match impl_item.node {
hir::ConstImplItem(..) |
hir::MethodImplItem(..) => {
hir::ImplItemKind::Const(..) |
hir::ImplItemKind::Method(..) => {
if opt_trait.is_some() ||
has_allow_dead_code_or_lang_attr(&impl_item.attrs) {
self.worklist.push(impl_item.id);
}
}
hir::TypeImplItem(_) => {}
hir::ImplItemKind::Type(_) => {}
}
}
}
Expand Down Expand Up @@ -571,21 +571,21 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {

fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) {
match impl_item.node {
hir::ConstImplItem(_, ref expr) => {
hir::ImplItemKind::Const(_, ref expr) => {
if !self.symbol_is_live(impl_item.id, None) {
self.warn_dead_code(impl_item.id, impl_item.span,
impl_item.name, "associated const");
}
visit::walk_expr(self, expr)
}
hir::MethodImplItem(_, ref body) => {
hir::ImplItemKind::Method(_, ref body) => {
if !self.symbol_is_live(impl_item.id, None) {
self.warn_dead_code(impl_item.id, impl_item.span,
impl_item.name, "method");
}
visit::walk_block(self, body)
}
hir::TypeImplItem(..) => {}
hir::ImplItemKind::Type(..) => {}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
}
ast_map::NodeImplItem(item) => {
match item.node {
hir::MethodImplItem(ref sig, _) => {
hir::ImplItemKind::Method(ref sig, _) => {
Some((&sig.decl,
&sig.generics,
sig.unsafety,
Expand Down Expand Up @@ -1838,7 +1838,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
},
ast_map::NodeImplItem(ii) => {
match ii.node {
hir::MethodImplItem(ref sig, _) => {
hir::ImplItemKind::Method(ref sig, _) => {
taken.push_all(&sig.generics.lifetimes);
Some(ii.id)
}
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
}
Some(ast_map::NodeImplItem(impl_item)) => {
match impl_item.node {
hir::ConstImplItem(..) => true,
hir::MethodImplItem(ref sig, _) => {
hir::ImplItemKind::Const(..) => true,
hir::ImplItemKind::Method(ref sig, _) => {
if generics_require_inlining(&sig.generics) ||
attr::requests_inline(&impl_item.attrs) {
true
Expand All @@ -206,7 +206,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
}
}
}
hir::TypeImplItem(_) => false,
hir::ImplItemKind::Type(_) => false,
}
}
Some(_) => false,
Expand Down Expand Up @@ -299,16 +299,16 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
}
ast_map::NodeImplItem(impl_item) => {
match impl_item.node {
hir::ConstImplItem(_, ref expr) => {
hir::ImplItemKind::Const(_, ref expr) => {
self.visit_expr(&*expr);
}
hir::MethodImplItem(ref sig, ref body) => {
hir::ImplItemKind::Method(ref sig, ref body) => {
let did = self.tcx.map.get_parent_did(search_item);
if method_might_be_inlined(self.tcx, sig, impl_item, did) {
visit::walk_block(self, body)
}
}
hir::TypeImplItem(_) => {}
hir::ImplItemKind::Type(_) => {}
}
}
// Nothing to recurse on for these
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
match cx.map.find(id) {
Some(ast_map::NodeImplItem(ref impl_item)) => {
match impl_item.node {
hir::TypeImplItem(_) => {
hir::ImplItemKind::Type(_) => {
// associated types don't have their own entry (for some reason),
// so for now just grab environment for the impl
let impl_id = cx.map.get_parent(id);
Expand All @@ -1136,7 +1136,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
&predicates,
id)
}
hir::ConstImplItem(_, _) => {
hir::ImplItemKind::Const(_, _) => {
let def_id = cx.map.local_def_id(id);
let scheme = cx.lookup_item_type(def_id);
let predicates = cx.lookup_predicates(def_id);
Expand All @@ -1145,7 +1145,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
&predicates,
id)
}
hir::MethodImplItem(_, ref body) => {
hir::ImplItemKind::Method(_, ref body) => {
let method_def_id = cx.map.local_def_id(id);
match cx.impl_or_trait_item(method_def_id) {
MethodTraitItem(ref method_ty) => {
Expand Down Expand Up @@ -2158,7 +2158,7 @@ impl<'tcx> ctxt<'tcx> {
}
ItemImpl(_, _, _, _, _, ref iis) => {
iis.iter().filter_map(|ii| {
if let hir::ConstImplItem(_, _) = ii.node {
if let hir::ImplItemKind::Const(_, _) = ii.node {
match self.impl_or_trait_item(self.map.local_def_id(ii.id)) {
ConstTraitItem(ac) => Some(ac),
_ => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for BorrowckCtxt<'a, 'tcx> {
}

fn visit_impl_item(&mut self, ii: &hir::ImplItem) {
if let hir::ConstImplItem(_, ref expr) = ii.node {
if let hir::ImplItemKind::Const(_, ref expr) = ii.node {
gather_loans::gather_loans_in_static_initializer(self, &*expr);
}
visit::walk_impl_item(self, ii);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ impl fold::Folder for ReplaceBodyWithLoop {

fn fold_impl_item(&mut self, i: P<ast::ImplItem>) -> SmallVector<P<ast::ImplItem>> {
match i.node {
ast::ConstImplItem(..) => {
ast::ImplItemKind::Const(..) => {
self.within_static_or_const = true;
let ret = fold::noop_fold_impl_item(i, self);
self.within_static_or_const = false;
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_front/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,13 +866,13 @@ pub fn noop_fold_impl_item<T: Folder>(i: P<ImplItem>, folder: &mut T) -> P<ImplI
attrs: fold_attrs(attrs, folder),
vis: vis,
node: match node {
ConstImplItem(ty, expr) => {
ConstImplItem(folder.fold_ty(ty), folder.fold_expr(expr))
ImplItemKind::Const(ty, expr) => {
ImplItemKind::Const(folder.fold_ty(ty), folder.fold_expr(expr))
}
MethodImplItem(sig, body) => {
MethodImplItem(noop_fold_method_sig(sig, folder), folder.fold_block(body))
ImplItemKind::Method(sig, body) => {
ImplItemKind::Method(noop_fold_method_sig(sig, folder), folder.fold_block(body))
}
TypeImplItem(ty) => TypeImplItem(folder.fold_ty(ty)),
ImplItemKind::Type(ty) => ImplItemKind::Type(folder.fold_ty(ty)),
},
span: folder.new_span(span),
}
Expand Down
11 changes: 5 additions & 6 deletions src/librustc_front/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub use self::ExplicitSelf_::*;
pub use self::Expr_::*;
pub use self::FunctionRetTy::*;
pub use self::ForeignItem_::*;
pub use self::ImplItem_::*;
pub use self::Item_::*;
pub use self::Mutability::*;
pub use self::Pat_::*;
Expand Down Expand Up @@ -771,15 +770,15 @@ pub struct ImplItem {
pub name: Name,
pub vis: Visibility,
pub attrs: Vec<Attribute>,
pub node: ImplItem_,
pub node: ImplItemKind,
pub span: Span,
}

#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum ImplItem_ {
ConstImplItem(P<Ty>, P<Expr>),
MethodImplItem(MethodSig, P<Block>),
TypeImplItem(P<Ty>),
pub enum ImplItemKind {
Const(P<Ty>, P<Expr>),
Method(MethodSig, P<Block>),
Type(P<Ty>),
}

// Bind a type to an associated type: `A=Foo`.
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_front/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,14 +677,14 @@ pub fn lower_impl_item(_lctx: &LoweringContext, i: &ImplItem) -> P<hir::ImplItem
attrs: i.attrs.clone(),
vis: lower_visibility(_lctx, i.vis),
node: match i.node {
ConstImplItem(ref ty, ref expr) => {
hir::ConstImplItem(lower_ty(_lctx, ty), lower_expr(_lctx, expr))
ImplItemKind::Const(ref ty, ref expr) => {
hir::ImplItemKind::Const(lower_ty(_lctx, ty), lower_expr(_lctx, expr))
}
MethodImplItem(ref sig, ref body) => {
hir::MethodImplItem(lower_method_sig(_lctx, sig), lower_block(_lctx, body))
ImplItemKind::Method(ref sig, ref body) => {
hir::ImplItemKind::Method(lower_method_sig(_lctx, sig), lower_block(_lctx, body))
}
TypeImplItem(ref ty) => hir::TypeImplItem(lower_ty(_lctx, ty)),
MacImplItem(..) => panic!("Shouldn't exist any more"),
ImplItemKind::Type(ref ty) => hir::ImplItemKind::Type(lower_ty(_lctx, ty)),
ImplItemKind::Macro(..) => panic!("Shouldn't exist any more"),
},
span: i.span,
})
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_front/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1006,16 +1006,16 @@ impl<'a> State<'a> {
try!(self.maybe_print_comment(ii.span.lo));
try!(self.print_outer_attributes(&ii.attrs));
match ii.node {
hir::ConstImplItem(ref ty, ref expr) => {
hir::ImplItemKind::Const(ref ty, ref expr) => {
try!(self.print_associated_const(ii.name, &ty, Some(&expr), ii.vis));
}
hir::MethodImplItem(ref sig, ref body) => {
hir::ImplItemKind::Method(ref sig, ref body) => {
try!(self.head(""));
try!(self.print_method_sig(ii.name, sig, ii.vis));
try!(self.nbsp());
try!(self.print_block_with_attrs(body, &ii.attrs));
}
hir::TypeImplItem(ref ty) => {
hir::ImplItemKind::Type(ref ty) => {
try!(self.print_associated_type(ii.name, None, Some(ty)));
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_front/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,18 +614,18 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
visitor.visit_name(impl_item.span, impl_item.name);
walk_list!(visitor, visit_attribute, &impl_item.attrs);
match impl_item.node {
ConstImplItem(ref ty, ref expr) => {
ImplItemKind::Const(ref ty, ref expr) => {
visitor.visit_ty(ty);
visitor.visit_expr(expr);
}
MethodImplItem(ref sig, ref body) => {
ImplItemKind::Method(ref sig, ref body) => {
visitor.visit_fn(FnKind::Method(impl_item.name, sig, Some(impl_item.vis)),
&sig.decl,
body,
impl_item.span,
impl_item.id);
}
TypeImplItem(ref ty) => {
ImplItemKind::Type(ref ty) => {
visitor.visit_ty(ty);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/bad_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ impl LateLintPass for NonUpperCaseGlobals {

fn check_impl_item(&mut self, cx: &LateContext, ii: &hir::ImplItem) {
match ii.node {
hir::ConstImplItem(..) => {
hir::ImplItemKind::Const(..) => {
NonUpperCaseGlobals::check_upper_case(cx, "associated constant",
ii.name, ii.span);
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,9 @@ impl LateLintPass for MissingDoc {
}

let desc = match impl_item.node {
hir::ConstImplItem(..) => "an associated constant",
hir::MethodImplItem(..) => "a method",
hir::TypeImplItem(_) => "an associated type",
hir::ImplItemKind::Const(..) => "an associated constant",
hir::ImplItemKind::Method(..) => "a method",
hir::ImplItemKind::Type(_) => "an associated type",
};
self.check_missing_docs_attrs(cx, Some(impl_item.id),
&impl_item.attrs,
Expand Down
Loading

0 comments on commit b31cc64

Please sign in to comment.