diff options
| author | csmoe <35686186+csmoe@users.noreply.github.com> | 2018-07-11 23:36:06 +0800 |
|---|---|---|
| committer | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-07-16 15:09:17 +0200 |
| commit | 5b0cf56f3212d0ec5f6daa083b6738e39209b07c (patch) | |
| tree | 959399797a7bc5e7937052b421497e50d4f8e373 | |
| parent | 7e5d22447264fe8cd5e89326f31bb6f0db3f885b (diff) | |
| download | rust-5b0cf56f3212d0ec5f6daa083b6738e39209b07c.tar.gz rust-5b0cf56f3212d0ec5f6daa083b6738e39209b07c.zip | |
ItemKind
61 files changed, 696 insertions, 696 deletions
diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 71f160dd321..3f6d34617c8 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -38,13 +38,13 @@ enum Target { impl Target { fn from_item(item: &hir::Item) -> Target { match item.node { - hir::ItemFn(..) => Target::Fn, - hir::ItemStruct(..) => Target::Struct, - hir::ItemUnion(..) => Target::Union, - hir::ItemEnum(..) => Target::Enum, - hir::ItemConst(..) => Target::Const, - hir::ItemForeignMod(..) => Target::ForeignMod, - hir::ItemStatic(..) => Target::Static, + hir::ItemKind::Fn(..) => Target::Fn, + hir::ItemKind::Struct(..) => Target::Struct, + hir::ItemKind::Union(..) => Target::Union, + hir::ItemKind::Enum(..) => Target::Enum, + hir::ItemKind::Const(..) => Target::Const, + hir::ItemKind::ForeignMod(..) => Target::ForeignMod, + hir::ItemKind::Static(..) => Target::Static, _ => Target::Other, } } @@ -340,7 +340,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { } fn is_c_like_enum(item: &hir::Item) -> bool { - if let hir::ItemEnum(ref def, _) = item.node { + if let hir::ItemKind::Enum(ref def, _) = item.node { for variant in &def.variants { match variant.node.data { hir::VariantData::Unit(_) => { /* continue */ } diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 401beeb6d20..8827576cd9c 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -463,23 +463,23 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { visitor.visit_vis(&item.vis); visitor.visit_name(item.span, item.name); match item.node { - ItemExternCrate(orig_name) => { + ItemKind::ExternCrate(orig_name) => { visitor.visit_id(item.id); if let Some(orig_name) = orig_name { visitor.visit_name(item.span, orig_name); } } - ItemUse(ref path, _) => { + ItemKind::Use(ref path, _) => { visitor.visit_id(item.id); visitor.visit_path(path, item.id); } - ItemStatic(ref typ, _, body) | - ItemConst(ref typ, body) => { + ItemKind::Static(ref typ, _, body) | + ItemKind::Const(ref typ, body) => { visitor.visit_id(item.id); visitor.visit_ty(typ); visitor.visit_nested_body(body); } - ItemFn(ref declaration, header, ref generics, body_id) => { + ItemKind::Fn(ref declaration, header, ref generics, body_id) => { visitor.visit_fn(FnKind::ItemFn(item.name, generics, header, @@ -490,23 +490,23 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { item.span, item.id) } - ItemMod(ref module) => { + ItemKind::Mod(ref module) => { // visit_mod() takes care of visiting the Item's NodeId visitor.visit_mod(module, item.span, item.id) } - ItemForeignMod(ref foreign_module) => { + ItemKind::ForeignMod(ref foreign_module) => { visitor.visit_id(item.id); walk_list!(visitor, visit_foreign_item, &foreign_module.items); } - ItemGlobalAsm(_) => { + ItemKind::GlobalAsm(_) => { visitor.visit_id(item.id); } - ItemTy(ref typ, ref type_parameters) => { + ItemKind::Ty(ref typ, ref type_parameters) => { visitor.visit_id(item.id); visitor.visit_ty(typ); visitor.visit_generics(type_parameters) } - ItemExistential(ExistTy {ref generics, ref bounds, impl_trait_fn}) => { + ItemKind::Existential(ExistTy {ref generics, ref bounds, impl_trait_fn}) => { visitor.visit_id(item.id); walk_generics(visitor, generics); walk_list!(visitor, visit_param_bound, bounds); @@ -514,31 +514,31 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { visitor.visit_def_mention(Def::Fn(impl_trait_fn)) } } - ItemEnum(ref enum_definition, ref type_parameters) => { + ItemKind::Enum(ref enum_definition, ref type_parameters) => { visitor.visit_generics(type_parameters); // visit_enum_def() takes care of visiting the Item's NodeId visitor.visit_enum_def(enum_definition, type_parameters, item.id, item.span) } - ItemImpl(.., ref type_parameters, ref opt_trait_reference, ref typ, ref impl_item_refs) => { + ItemKind::Impl(.., ref type_parameters, ref opt_trait_reference, ref typ, ref impl_item_refs) => { visitor.visit_id(item.id); visitor.visit_generics(type_parameters); walk_list!(visitor, visit_trait_ref, opt_trait_reference); visitor.visit_ty(typ); walk_list!(visitor, visit_impl_item_ref, impl_item_refs); } - ItemStruct(ref struct_definition, ref generics) | - ItemUnion(ref struct_definition, ref generics) => { + ItemKind::Struct(ref struct_definition, ref generics) | + ItemKind::Union(ref struct_definition, ref generics) => { visitor.visit_generics(generics); visitor.visit_id(item.id); visitor.visit_variant_data(struct_definition, item.name, generics, item.id, item.span); } - ItemTrait(.., ref generics, ref bounds, ref trait_item_refs) => { + ItemKind::Trait(.., ref generics, ref bounds, ref trait_item_refs) => { visitor.visit_id(item.id); visitor.visit_generics(generics); walk_list!(visitor, visit_param_bound, bounds); walk_list!(visitor, visit_trait_item_ref, trait_item_refs); } - ItemTraitAlias(ref generics, ref bounds) => { + ItemKind::TraitAlias(ref generics, ref bounds) => { visitor.visit_id(item.id); visitor.visit_generics(generics); walk_list!(visitor, visit_param_bound, bounds); diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index d1cc061fdfd..31484f33732 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -384,8 +384,8 @@ impl<'a> LoweringContext<'a> { if item_lowered { let item_generics = match self.lctx.items.get(&item.id).unwrap().node { - hir::Item_::ItemImpl(_, _, _, ref generics, ..) - | hir::Item_::ItemTrait(_, _, ref generics, ..) => { + hir::ItemKind::Impl(_, _, _, ref generics, ..) + | hir::ItemKind::Trait(_, _, ref generics, ..) => { generics.params.clone() } _ => HirVec::new(), @@ -1274,7 +1274,7 @@ impl<'a> LoweringContext<'a> { ); self.with_hir_id_owner(exist_ty_node_id, |lctx| { - let exist_ty_item_kind = hir::ItemExistential(hir::ExistTy { + let exist_ty_item_kind = hir::ItemKind::Existential(hir::ExistTy { generics: hir::Generics { params: lifetime_defs, where_clause: hir::WhereClause { @@ -2575,9 +2575,9 @@ impl<'a> LoweringContext<'a> { attrs: &hir::HirVec<Attribute>, vis: &mut hir::Visibility, i: &ItemKind, - ) -> hir::Item_ { + ) -> hir::ItemKind { match *i { - ItemKind::ExternCrate(orig_name) => hir::ItemExternCrate(orig_name), + ItemKind::ExternCrate(orig_name) => hir::ItemKind::ExternCrate(orig_name), ItemKind::Use(ref use_tree) => { // Start with an empty prefix let prefix = Path { @@ -2589,7 +2589,7 @@ impl<'a> LoweringContext<'a> { } ItemKind::Static(ref t, m, ref e) => { let value = self.lower_body(None, |this| this.lower_expr(e)); - hir::ItemStatic( + hir::ItemKind::Static( self.lower_ty(t, ImplTraitContext::Disallowed), self.lower_mutability(m), value, @@ -2597,7 +2597,7 @@ impl<'a> LoweringContext<'a> { } ItemKind::Const(ref t, ref e) => { let value = self.lower_body(None, |this| this.lower_expr(e)); - hir::ItemConst(self.lower_ty(t, ImplTraitContext::Disallowed), value) + hir::ItemKind::Const(self.lower_ty(t, ImplTraitContext::Disallowed), value) } ItemKind::Fn(ref decl, header, ref generics, ref body) => { let fn_def_id = self.resolver.definitions().local_def_id(id); @@ -2617,7 +2617,7 @@ impl<'a> LoweringContext<'a> { decl, Some((fn_def_id, idty)), true, header.asyncness.opt_return_id()), ); - hir::ItemFn( + hir::ItemKind::Fn( fn_decl, this.lower_fn_header(header), generics, @@ -2625,14 +2625,14 @@ impl<'a> LoweringContext<'a> { ) }) } - ItemKind::Mod(ref m) => hir::ItemMod(self.lower_mod(m)), - ItemKind::ForeignMod(ref nm) => hir::ItemForeignMod(self.lower_foreign_mod(nm)), - ItemKind::GlobalAsm(ref ga) => hir::ItemGlobalAsm(self.lower_global_asm(ga)), - ItemKind::Ty(ref t, ref generics) => hir::ItemTy( + ItemKind::Mod(ref m) => hir::ItemKind::Mod(self.lower_mod(m)), + ItemKind::ForeignMod(ref nm) => hir::ItemKind::ForeignMod(self.lower_foreign_mod(nm)), + ItemKind::GlobalAsm(ref ga) => hir::ItemKind::GlobalAsm(self.lower_global_asm(ga)), + ItemKind::Ty(ref t, ref generics) => hir::ItemKind::Ty( self.lower_ty(t, ImplTraitContext::Disallowed), self.lower_generics(generics, ImplTraitContext::Disallowed), ), - ItemKind::Enum(ref enum_definition, ref generics) => hir::ItemEnum( + ItemKind::Enum(ref enum_definition, ref generics) => hir::ItemKind::Enum( hir::EnumDef { variants: enum_definition .variants @@ -2644,14 +2644,14 @@ impl<'a> LoweringContext<'a> { ), ItemKind::Struct(ref struct_def, ref generics) => { let struct_def = self.lower_variant_data(struct_def); - hir::ItemStruct( + hir::ItemKind::Struct( struct_def, self.lower_generics(generics, ImplTraitContext::Disallowed), ) } ItemKind::Union(ref vdata, ref generics) => { let vdata = self.lower_variant_data(vdata); - hir::ItemUnion( + hir::ItemKind::Union( vdata, self.lower_generics(generics, ImplTraitContext::Disallowed), ) @@ -2711,7 +2711,7 @@ impl<'a> LoweringContext<'a> { }, ); - hir::ItemImpl( + hir::ItemKind::Impl( self.lower_unsafety(unsafety), self.lower_impl_polarity(polarity), self.lower_defaultness(defaultness, true /* [1] */), @@ -2727,7 +2727,7 @@ impl<'a> LoweringContext<'a> { .iter() .map(|item| self.lower_trait_item_ref(item)) .collect(); - hir::ItemTrait( + hir::ItemKind::Trait( self.lower_is_auto(is_auto), self.lower_unsafety(unsafety), self.lower_generics(generics, ImplTraitContext::Disallowed), @@ -2735,7 +2735,7 @@ impl<'a> LoweringContext<'a> { items, ) } - ItemKind::TraitAlias(ref generics, ref bounds) => hir::ItemTraitAlias( + ItemKind::TraitAlias(ref generics, ref bounds) => hir::ItemKind::TraitAlias( self.lower_generics(generics, ImplTraitContext::Disallowed), self.lower_param_bounds(bounds, ImplTraitContext::Disallowed), ), @@ -2754,7 +2754,7 @@ impl<'a> LoweringContext<'a> { vis: &mut hir::Visibility, name: &mut Name, attrs: &hir::HirVec<Attribute>, - ) -> hir::Item_ { + ) -> hir::ItemKind { let path = &tree.prefix; match tree.kind { @@ -2804,7 +2804,7 @@ impl<'a> LoweringContext<'a> { self.with_hir_id_owner(new_node_id, |this| { let new_id = this.lower_node_id(new_node_id); let path = this.lower_path_extra(def, &path, None, ParamMode::Explicit); - let item = hir::ItemUse(P(path), hir::UseKind::Single); + let item = hir::ItemKind::Use(P(path), hir::UseKind::Single); let vis_kind = match vis.node { hir::VisibilityKind::Public => hir::VisibilityKind::Public, hir::VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar), @@ -2835,7 +2835,7 @@ impl<'a> LoweringContext<'a> { } let path = P(self.lower_path_extra(ret_def, &path, None, ParamMode::Explicit)); - hir::ItemUse(path, hir::UseKind::Single) + hir::ItemKind::Use(path, hir::UseKind::Single) } UseTreeKind::Glob => { let path = P(self.lower_path( @@ -2851,7 +2851,7 @@ impl<'a> LoweringContext<'a> { }, ParamMode::Explicit, )); - hir::ItemUse(path, hir::UseKind::Glob) + hir::ItemKind::Use(path, hir::UseKind::Glob) } UseTreeKind::Nested(ref trees) => { let prefix = Path { @@ -2912,7 +2912,7 @@ impl<'a> LoweringContext<'a> { // a re-export by accident when `pub`, e.g. in documentation. let path = P(self.lower_path(id, &prefix, ParamMode::Explicit)); *vis = respan(prefix.span.shrink_to_lo(), hir::VisibilityKind::Inherited); - hir::ItemUse(path, hir::UseKind::ListStem) + hir::ItemKind::Use(path, hir::UseKind::ListStem) } } } diff --git a/src/librustc/hir/map/blocks.rs b/src/librustc/hir/map/blocks.rs index 6d4bff5a352..5a595d14db7 100644 --- a/src/librustc/hir/map/blocks.rs +++ b/src/librustc/hir/map/blocks.rs @@ -47,7 +47,7 @@ pub trait MaybeFnLike { fn is_fn_like(&self) -> bool; } impl MaybeFnLike for ast::Item { fn is_fn_like(&self) -> bool { - match self.node { ast::ItemFn(..) => true, _ => false, } + match self.node { ast::ItemKind::Fn(..) => true, _ => false, } } } @@ -229,7 +229,7 @@ impl<'a> FnLikeNode<'a> { { match self.node { map::NodeItem(i) => match i.node { - ast::ItemFn(ref decl, header, ref generics, block) => + ast::ItemKind::Fn(ref decl, header, ref generics, block) => item_fn(ItemFnParts { id: i.id, name: i.name, diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 3cc25bfd2d4..0150ba659c9 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -329,7 +329,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { this.insert(i.id, NodeItem(i)); this.with_parent(i.id, |this| { match i.node { - ItemStruct(ref struct_def, _) => { + ItemKind::Struct(ref struct_def, _) => { // If this is a tuple-like struct, register the constructor. if !struct_def.is_struct() { this.insert(struct_def.id(), NodeStructCtor(struct_def)); diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs index b90bca84ed6..656f325b4dd 100644 --- a/src/librustc/hir/map/hir_id_validator.rs +++ b/src/librustc/hir/map/hir_id_validator.rs @@ -179,7 +179,7 @@ impl<'a, 'hir: 'a> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> { fn visit_impl_item_ref(&mut self, _: &'hir hir::ImplItemRef) { // Explicitly do nothing here. ImplItemRefs contain hir::Visibility - // values that actually belong to an ImplItem instead of the ItemImpl + // values that actually belong to an ImplItem instead of the ItemKind::Impl // we are currently in. So for those it's correct that they have a // different owner. } diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index d9ee77dbe24..d413a544c4e 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -175,7 +175,7 @@ impl<'hir> MapEntry<'hir> { match self { EntryItem(_, _, ref item) => { match item.node { - ItemFn(ref fn_decl, _, _, _) => Some(&fn_decl), + ItemKind::Fn(ref fn_decl, _, _, _) => Some(&fn_decl), _ => None, } } @@ -209,9 +209,9 @@ impl<'hir> MapEntry<'hir> { match self { EntryItem(_, _, item) => { match item.node { - ItemConst(_, body) | - ItemStatic(.., body) | - ItemFn(_, _, _, body) => Some(body), + ItemKind::Const(_, body) | + ItemKind::Static(.., body) | + ItemKind::Fn(_, _, _, body) => Some(body), _ => None, } } @@ -427,25 +427,25 @@ impl<'hir> Map<'hir> { }; match item.node { - ItemStatic(_, m, _) => Some(Def::Static(def_id(), + ItemKind::Static(_, m, _) => Some(Def::Static(def_id(), m == MutMutable)), - ItemConst(..) => Some(Def::Const(def_id())), - ItemFn(..) => Some(Def::Fn(def_id())), - ItemMod(..) => Some(Def::Mod(def_id())), - ItemGlobalAsm(..) => Some(Def::GlobalAsm(def_id())), - ItemExistential(..) => Some(Def::Existential(def_id())), - ItemTy(..) => Some(Def::TyAlias(def_id())), - ItemEnum(..) => Some(Def::Enum(def_id())), - ItemStruct(..) => Some(Def::Struct(def_id())), - ItemUnion(..) => Some(Def::Union(def_id())), - ItemTrait(..) => Some(Def::Trait(def_id())), - ItemTraitAlias(..) => { + ItemKind::Const(..) => Some(Def::Const(def_id())), + ItemKind::Fn(..) => Some(Def::Fn(def_id())), + ItemKind::Mod(..) => Some(Def::Mod(def_id())), + ItemKind::GlobalAsm(..) => Some(Def::GlobalAsm(def_id())), + ItemKind::Existential(..) => Some(Def::Existential(def_id())), + ItemKind::Ty(..) => Some(Def::TyAlias(def_id())), + ItemKind::Enum(..) => Some(Def::Enum(def_id())), + ItemKind::Struct(..) => Some(Def::Struct(def_id())), + ItemKind::Union(..) => Some(Def::Union(def_id())), + ItemKind::Trait(..) => Some(Def::Trait(def_id())), + ItemKind::TraitAlias(..) => { bug!("trait aliases are not yet implemented (see issue #41517)") }, - ItemExternCrate(_) | - ItemUse(..) | - ItemForeignMod(..) | - ItemImpl(..) => None, + ItemKind::ExternCrate(_) | + ItemKind::Use(..) | + ItemKind::ForeignMod(..) | + ItemKind::Impl(..) => None, } } NodeForeignItem(item) => { @@ -587,13 +587,13 @@ impl<'hir> Map<'hir> { pub fn body_owner_kind(&self, id: NodeId) -> BodyOwnerKind { match self.get(id) { - NodeItem(&Item { node: ItemConst(..), .. }) | + NodeItem(&Item { node: ItemKind::Const(..), .. }) | NodeTraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) | NodeImplItem(&ImplItem { node: ImplItemKind::Const(..), .. }) | NodeAnonConst(_) => { BodyOwnerKind::Const } - NodeItem(&Item { node: ItemStatic(_, m, _), .. }) => { + NodeItem(&Item { node: ItemKind::Static(_, m, _), .. }) => { BodyOwnerKind::Static(m) } // Default to function if it's not a constant or static. @@ -603,7 +603,7 @@ impl<'hir> Map<'hir> { pub fn ty_param_owner(&self, id: NodeId) -> NodeId { match self.get(id) { - NodeItem(&Item { node: ItemTrait(..), .. }) => id, + NodeItem(&Item { node: ItemKind::Trait(..), .. }) => id, NodeGenericParam(_) => self.get_parent_node(id), _ => { bug!("ty_param_owner: {} not a type parameter", @@ -614,7 +614,7 @@ impl<'hir> Map<'hir> { pub fn ty_param_name(&self, id: NodeId) -> Name { match self.get(id) { - NodeItem(&Item { node: ItemTrait(..), .. }) => { + NodeItem(&Item { node: ItemKind::Trait(..), .. }) => { keywords::SelfType.name() } NodeGenericParam(param) => param.name.ident().name, @@ -672,14 +672,14 @@ impl<'hir> Map<'hir> { NodeTraitItem(ref trait_item) => Some(&trait_item.generics), NodeItem(ref item) => { match item.node { - ItemFn(_, _, ref generics, _) | - ItemTy(_, ref generics) | - ItemEnum(_, ref generics) | - ItemStruct(_, ref generics) | - ItemUnion(_, ref generics) | - ItemTrait(_, _, ref generics, ..) | - ItemTraitAlias(ref generics, _) | - ItemImpl(_, _, _, ref generics, ..) => Some(generics), + ItemKind::Fn(_, _, ref generics, _) | + ItemKind::Ty(_, ref generics) | + ItemKind::Enum(_, ref generics) | + ItemKind::Struct(_, ref generics) | + ItemKind::Union(_, ref generics) | + ItemKind::Trait(_, _, ref generics, ..) | + ItemKind::TraitAlias(ref generics, _) | + ItemKind::Impl(_, _, _, ref generics, ..) => Some(generics), _ => None, } } @@ -857,7 +857,7 @@ impl<'hir> Map<'hir> { /// module parent is in this map. pub fn get_module_parent(&self, id: NodeId) -> DefId { let id = match self.walk_parent_nodes(id, |node| match *node { - NodeItem(&Item { node: Item_::ItemMod(_), .. }) => true, + NodeItem(&Item { node: ItemKind::Mod(_), .. }) => true, _ => false, }, |_| false) { Ok(id) => id, @@ -893,7 +893,7 @@ impl<'hir> Map<'hir> { let abi = match self.find_entry(parent) { Some(EntryItem(_, _, i)) => { match i.node { - ItemForeignMod(ref nm) => Some(nm.abi), + ItemKind::ForeignMod(ref nm) => Some(nm.abi), _ => None } } @@ -934,8 +934,8 @@ impl<'hir> Map<'hir> { match self.find(id) { Some(NodeItem(i)) => { match i.node { - ItemStruct(ref struct_def, _) | - ItemUnion(ref struct_def, _) => struct_def, + ItemKind::Struct(ref struct_def, _) | + ItemKind::Union(ref struct_def, _) => struct_def, _ => { bug!("struct ID bound to non-struct {}", self.node_to_string(id)); @@ -1129,7 +1129,7 @@ impl<'a, 'hir> NodesMatchingSuffix<'a, 'hir> { fn item_is_mod(item: &Item) -> bool { match item.node { - ItemMod(_) => true, + ItemKind::Mod(_) => true, _ => false, } } @@ -1314,22 +1314,22 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String { match map.find(id) { Some(NodeItem(item)) => { let item_str = match item.node { - ItemExternCrate(..) => "extern crate", - ItemUse(..) => "use", - ItemStatic(..) => "static", - ItemConst(..) => "const", - ItemFn(..) => "fn", - ItemMod(..) => "mod", - ItemForeignMod(..) => "foreign mod", - ItemGlobalAsm(..) => "global asm", - ItemTy(..) => "ty", - ItemExistential(..) => "existential", - ItemEnum(..) => "enum", - ItemStruct(..) => "struct", - ItemUnion(..) => "union", - ItemTrait(..) => "trait", - ItemTraitAlias(..) => "trait alias", - ItemImpl(..) => "impl", + ItemKind::ExternCrate(..) => "extern crate", + ItemKind::Use(..) => "use", + ItemKind::Static(..) => "static", + ItemKind::Const(..) => "const", + ItemKind::Fn(..) => "fn", + ItemKind::Mod(..) => "mod", + ItemKind::ForeignMod(..) => "foreign mod", + ItemKind::GlobalAsm(..) => "global asm", + ItemKind::Ty(..) => "ty", + ItemKind::Existential(..) => "existential", + ItemKind::Enum(..) => "enum", + ItemKind::Struct(..) => "struct", + ItemKind::Union(..) => "union", + ItemKind::Trait(..) => "trait", + ItemKind::TraitAlias(..) => "trait alias", + ItemKind::Impl(..) => "impl", }; format!("{} {}{}", item_str, path_str(), id_str) } diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index ac7a9b4257a..c1a885d80bf 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -13,7 +13,6 @@ pub use self::BlockCheckMode::*; pub use self::CaptureClause::*; pub use self::FunctionRetTy::*; -pub use self::Item_::*; pub use self::Mutability::*; pub use self::PrimTy::*; pub use self::UnOp::*; @@ -2040,7 +2039,7 @@ pub struct Item { pub id: NodeId, pub hir_id: HirId, pub attrs: HirVec<Attribute>, - pub node: Item_, + pub node: ItemKind, pub vis: Visibility, pub span: Span, } @@ -2054,96 +2053,96 @@ pub struct FnHeader { } #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] -pub enum Item_ { +pub enum ItemKind { /// An `extern crate` item, with optional *original* crate name if the crate was renamed. /// /// E.g. `extern crate foo` or `extern crate foo_bar as foo` - ItemExternCrate(Option<Name>), + ExternCrate(Option<Name>), /// `use foo::bar::*;` or `use foo::bar::baz as quux;` /// /// or just /// /// `use foo::bar::baz;` (with `as baz` implicitly on the right) - ItemUse(P<Path>, UseKind), + Use(P<Path>, UseKind), /// A `static` item - ItemStatic(P<Ty>, Mutability, BodyId), + Static(P<Ty>, Mutability, BodyId), /// A `const` item - ItemConst(P<Ty>, BodyId), + Const(P<Ty>, BodyId), /// A function declaration - ItemFn(P<FnDecl>, FnHeader, Generics, BodyId), + Fn(P<FnDecl>, FnHeader, Generics, BodyId), /// A module - ItemMod(Mod), + Mod(Mod), /// An external module - ItemForeignMod(ForeignMod), + ForeignMod(ForeignMod), /// Module-level inline assembly (from global_asm!) - ItemGlobalAsm(P<GlobalAsm>), + GlobalAsm(P<GlobalAsm>), /// A type alias, e.g. `type Foo = Bar<u8>` - ItemTy(P<Ty>, Generics), + Ty(P<Ty>, Generics), /// A type alias, e.g. `type Foo = Bar<u8>` - ItemExistential(ExistTy), + Existential(ExistTy), /// An enum definition, e.g. `enum Foo<A, B> {C<A>, D<B>}` - ItemEnum(EnumDef, Generics), + Enum(EnumDef, Generics), /// A struct definition, e.g. `struct Foo<A> {x: A}` - ItemStruct(VariantData, Generics), + Struct(VariantData, Generics), /// A union definition, e.g. `union Foo<A, B> {x: A, y: B}` - ItemUnion(VariantData, Generics), + Union(VariantData, Generics), /// Represents a Trait Declaration - ItemTrait(IsAuto, Unsafety, Generics, GenericBounds, HirVec<TraitItemRef>), + Trait(IsAuto, Unsafety, Generics, GenericBounds, HirVec<TraitItemRef>), /// Represents a Trait Alias Declaration - ItemTraitAlias(Generics, GenericBounds), + TraitAlias(Generics, GenericBounds), /// An implementation, eg `impl<A> Trait for Foo { .. }` - ItemImpl(Unsafety, - ImplPolarity, - Defaultness, - Generics, - Option<TraitRef>, // (optional) trait this impl implements - P<Ty>, // self - HirVec<ImplItemRef>), + Impl(Unsafety, + ImplPolarity, + Defaultness, + Generics, + Option<TraitRef>, // (optional) trait this impl implements + P<Ty>, // self + HirVec<ImplItemRef>), } -impl Item_ { +impl ItemKind { pub fn descriptive_variant(&self) -> &str { match *self { - ItemExternCrate(..) => "extern crate", - ItemUse(..) => "use", - ItemStatic(..) => "static item", - ItemConst(..) => "constant item", - ItemFn(..) => "function", - ItemMod(..) => "module", - ItemForeignMod(..) => "foreign module", - ItemGlobalAsm(..) => "global asm", - ItemTy(..) => "type alias", - ItemExistential(..) => "existential type", - ItemEnum(..) => "enum", - ItemStruct(..) => "struct", - ItemUnion(..) => "union", - ItemTrait(..) => "trait", - ItemTraitAlias(..) => "trait alias", - ItemImpl(..) => "item", + ItemKind::ExternCrate(..) => "extern crate", + ItemKind::Use(..) => "use", + ItemKind::Static(..) => "static item", + ItemKind::Const(..) => "constant item", + ItemKind::Fn(..) => "function", + ItemKind::Mod(..) => "module", + ItemKind::ForeignMod(..) => "foreign module", + ItemKind::GlobalAsm(..) => "global asm", + ItemKind::Ty(..) => "type alias", + ItemKind::Existential(..) => "existential type", + ItemKind::Enum(..) => "enum", + ItemKind::Struct(..) => "struct", + ItemKind::Union(..) => "union", + ItemKind::Trait(..) => "trait", + ItemKind::TraitAlias(..) => "trait alias", + ItemKind::Impl(..) => "item", } } pub fn adt_kind(&self) -> Option<AdtKind> { match *self { - ItemStruct(..) => Some(AdtKind::Struct), - ItemUnion(..) => Some(AdtKind::Union), - ItemEnum(..) => Some(AdtKind::Enum), + ItemKind::Struct(..) => Some(AdtKind::Struct), + ItemKind::Union(..) => Some(AdtKind::Union), + ItemKind::Enum(..) => Some(AdtKind::Enum), _ => None, } } pub fn generics(&self) -> Option<&Generics> { Some(match *self { - ItemFn(_, _, ref generics, _) | - ItemTy(_, ref generics) | - ItemEnum(_, ref generics) | - ItemStruct(_, ref generics) | - ItemUnion(_, ref generics) | - ItemTrait(_, _, ref generics, _, _) | - ItemImpl(_, _, _, ref generics, _, _, _)=> generics, + ItemKind::Fn(_, _, ref generics, _) | + ItemKind::Ty(_, ref generics) | + ItemKind::Enum(_, ref generics) | + ItemKind::Struct(_, ref generics) | + ItemKind::Union(_, ref generics) | + ItemKind::Trait(_, _, ref generics, _, _) | + ItemKind::Impl(_, _, _, ref generics, _, _, _)=> generics, _ => return None }) } diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 9d211535063..e637a18d1cd 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -531,7 +531,7 @@ impl<'a> State<'a> { self.print_outer_attributes(&item.attrs)?; self.ann.pre(self, NodeItem(item))?; match item.node { - hir::ItemExternCrate(orig_name) => { + hir::ItemKind::ExternCrate(orig_name) => { self.head(&visibility_qualified(&item.vis, "extern crate"))?; if let Some(orig_name) = orig_name { self.print_name(orig_name)?; @@ -544,7 +544,7 @@ impl<'a> State<'a> { self.end()?; // end inner head-block self.end()?; // end outer head-block } - hir::ItemUse(ref path, kind) => { + hir::ItemKind::Use(ref path, kind) => { self.head(&visibility_qualified(&item.vis, "use"))?; self.print_path(path, false)?; @@ -563,7 +563,7 @@ impl<'a> State<'a> { self.end()?; // end inner head-block self.end()?; // end outer head-block } - hir::ItemStatic(ref ty, m, expr) => { + hir::ItemKind::Static(ref ty, m, expr) => { self.head(&visibility_qualified(&item.vis, "static"))?; if m == hir::MutMutable { self.word_space("mut")?; @@ -579,7 +579,7 @@ impl<'a> State<'a> { self.s.word(";")?; self.end()?; // end the outer cbox } - hir::ItemConst(ref ty, expr) => { + hir::ItemKind::Const(ref ty, expr) => { self.head(&visibility_qualified(&item.vis, "const"))?; self.print_name(item.name)?; self.word_space(":")?; @@ -592,7 +592,7 @@ impl<'a> State<'a> { self.s.word(";")?; self.end()?; // end the outer cbox } - hir::ItemFn(ref decl, header, ref typarams, body) => { + hir::ItemKind::Fn(ref decl, header, ref typarams, body) => { self.head("")?; self.print_fn(decl, header, @@ -606,7 +606,7 @@ impl<'a> State<'a> { self.end()?; // need to close a box self.ann.nested(self, Nested::Body(body))?; } - hir::ItemMod(ref _mod) => { + hir::ItemKind::Mod(ref _mod) => { self.head(&visibility_qualified(&item.vis, "mod"))?; self.print_name(item.name)?; self.nbsp()?; @@ -614,19 +614,19 @@ impl<'a> State<'a> { self.print_mod(_mod, &item.attrs)?; self.bclose(item.span)?; } - hir::ItemForeignMod(ref nmod) => { + hir::ItemKind::ForeignMod(ref nmod) => { self.head("extern")?; self.word_nbsp(&nmod.abi.to_string())?; self.bopen()?; self.print_foreign_mod(nmod, &item.attrs)?; self.bclose(item.span)?; } - hir::ItemGlobalAsm(ref ga) => { + hir::ItemKind::GlobalAsm(ref ga) => { self.head(&visibility_qualified(&item.vis, "global asm"))?; self.s.word(&ga.asm.as_str())?; self.end()? } - hir::ItemTy(ref ty, ref generics) => { + hir::ItemKind::Ty(ref ty, ref generics) => { self.ibox(indent_unit)?; self.ibox(0)?; self.word_nbsp(&visibility_qualified(&item.vis, "type"))?; @@ -641,7 +641,7 @@ impl<'a> State<'a> { self.s.word(";")?; self.end()?; // end the outer ibox } - hir::ItemExistential(ref exist) => { + hir::ItemKind::Existential(ref exist) => { self.ibox(indent_unit)?; self.ibox(0)?; self.word_nbsp(&visibility_qualified(&item.vis, "existential type"))?; @@ -666,18 +666,18 @@ impl<'a> State<'a> { self.s.word(";")?; self.end()?; // end the outer ibox } - hir::ItemEnum(ref enum_definition, ref params) => { + hir::ItemKind::Enum(ref enum_definition, ref params) => { self.print_enum_def(enum_definition, params, item.name, item.span, &item.vis)?; } - hir::ItemStruct(ref struct_def, ref generics) => { + hir::ItemKind::Struct(ref struct_def, ref generics) => { self.head(&visibility_qualified(&item.vis, "struct"))?; self.print_struct(struct_def, generics, item.name, item.span, true)?; } - hir::ItemUnion(ref struct_def, ref generics) => { + hir::ItemKind::Union(ref struct_def, ref generics) => { self.head(&visibility_qualified(&item.vis, "union"))?; self.print_struct(struct_def, generics, item.name, item.span, true)?; } - hir::ItemImpl(unsafety, + hir::ItemKind::Impl(unsafety, polarity, defaultness, ref generics, @@ -722,7 +722,7 @@ impl<'a> State<'a> { } self.bclose(item.span)?; } - hir::ItemTrait(is_auto, unsafety, ref generics, ref bounds, ref trait_items) => { + hir::ItemKind::Trait(is_auto, unsafety, ref generics, ref bounds, ref trait_items) => { self.head("")?; self.print_visibility(&item.vis)?; self.print_is_auto(is_auto)?; @@ -749,7 +749,7 @@ impl<'a> State<'a> { } self.bclose(item.span)?; } - hir::ItemTraitAlias(ref generics, ref bounds) => { + hir::ItemKind::TraitAlias(ref generics, ref bounds) => { self.head("")?; self.print_visibility(&item.vis)?; self.word_nbsp("trait")?; diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index d00f96834ab..d1fb05ceafb 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -847,23 +847,23 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Item { } } -impl_stable_hash_for!(enum hir::Item_ { - ItemExternCrate(orig_name), - ItemUse(path, use_kind), - ItemStatic(ty, mutability, body_id), - ItemConst(ty, body_id), - ItemFn(fn_decl, header, generics, body_id), - ItemMod(module), - ItemForeignMod(foreign_mod), - ItemGlobalAsm(global_asm), - ItemTy(ty, generics), - ItemExistential(exist), - ItemEnum(enum_def, generics), - ItemStruct(variant_data, generics), - ItemUnion(variant_data, generics), - ItemTrait(is_auto, unsafety, generics, bounds, item_refs), - ItemTraitAlias(generics, bounds), - ItemImpl(unsafety, impl_polarity, impl_defaultness, generics, trait_ref, ty, impl_item_refs) +impl_stable_hash_for!(enum hir::ItemKind { + ExternCrate(orig_name), + Use(path, use_kind), + Static(ty, mutability, body_id), + Const(ty, body_id), + Fn(fn_decl, header, generics, body_id), + Mod(module), + ForeignMod(foreign_mod), + GlobalAsm(global_asm), + Ty(ty, generics), + Existential(exist), + Enum(enum_def, generics), + Struct(variant_data, generics), + Union(variant_data, generics), + Trait(is_auto, unsafety, generics, bounds, item_refs), + TraitAlias(generics, bounds), + Impl(unsafety, impl_polarity, impl_defaultness, generics, trait_ref, ty, impl_item_refs) }); impl_stable_hash_for!(struct hir::TraitItemRef { diff --git a/src/librustc/infer/anon_types/mod.rs b/src/librustc/infer/anon_types/mod.rs index 5487da97d5b..2924016670b 100644 --- a/src/librustc/infer/anon_types/mod.rs +++ b/src/librustc/infer/anon_types/mod.rs @@ -691,7 +691,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> { // ``` if let Some(anon_node_id) = tcx.hir.as_local_node_id(def_id) { let anon_parent_def_id = match tcx.hir.expect_item(anon_node_id).node { - hir::ItemExistential(hir::ExistTy { + hir::ItemKind::Existential(hir::ExistTy { impl_trait_fn: Some(parent), .. }) => parent, diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 680d1623742..8da0dc365b0 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -259,12 +259,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { fn item_scope_tag(item: &hir::Item) -> &'static str { match item.node { - hir::ItemImpl(..) => "impl", - hir::ItemStruct(..) => "struct", - hir::ItemUnion(..) => "union", - hir::ItemEnum(..) => "enum", - hir::ItemTrait(..) => "trait", - hir::ItemFn(..) => "function body", + hir::ItemKind::Impl(..) => "impl", + hir::ItemKind::Struct(..) => "struct", + hir::ItemKind::Union(..) => "union", + hir::ItemKind::Enum(..) => "enum", + hir::ItemKind::Trait(..) => "trait", + hir::ItemKind::Fn(..) => "function body", _ => "item", } } diff --git a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs index 022d4fb8d1e..21be09b0ba1 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -41,7 +41,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { let fndecl = match self.tcx.hir.get(node_id) { hir_map::NodeItem(&hir::Item { - node: hir::ItemFn(ref fndecl, ..), + node: hir::ItemKind::Fn(ref fndecl, ..), .. }) => &fndecl, hir_map::NodeTraitItem(&hir::TraitItem { diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 0e3ae7ca70f..da59bced760 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -153,21 +153,21 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { match *node { hir_map::NodeItem(item) => { match item.node { - hir::ItemStruct(..) | hir::ItemUnion(..) => { + hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => { let def_id = self.tcx.hir.local_def_id(item.id); let def = self.tcx.adt_def(def_id); self.repr_has_repr_c = def.repr.c(); intravisit::walk_item(self, &item); } - hir::ItemEnum(..) => { + hir::ItemKind::Enum(..) => { self.inherited_pub_visibility = item.vis.node.is_pub(); intravisit::walk_item(self, &item); } - hir::ItemFn(..) - | hir::ItemTy(..) - | hir::ItemStatic(..) - | hir::ItemConst(..) => { + hir::ItemKind::Fn(..) + | hir::ItemKind::Ty(..) + | hir::ItemKind::Static(..) + | hir::ItemKind::Const(..) => { intravisit::walk_item(self, &item); } _ => () @@ -349,11 +349,11 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> { self.worklist.push(item.id); } match item.node { - hir::ItemEnum(ref enum_def, _) if allow_dead_code => { + hir::ItemKind::Enum(ref enum_def, _) if allow_dead_code => { self.worklist.extend(enum_def.variants.iter() .map(|variant| variant.node.data.id())); } - hir::ItemTrait(.., ref trait_item_refs) => { + hir::ItemKind::Trait(.., ref trait_item_refs) => { for trait_item_ref in trait_item_refs { let trait_item = self.krate.trait_item(trait_item_ref.id); match trait_item.node { @@ -369,7 +369,7 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> { } } } - hir::ItemImpl(.., ref opt_trait, _, ref impl_item_refs) => { + hir::ItemKind::Impl(.., ref opt_trait, _, ref impl_item_refs) => { for impl_item_ref in impl_item_refs { let impl_item = self.krate.impl_item(impl_item_ref.id); if opt_trait.is_some() || @@ -439,7 +439,7 @@ fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn get_struct_ctor_id(item: &hir::Item) -> Option<ast::NodeId> { match item.node { - hir::ItemStruct(ref struct_def, _) if !struct_def.is_struct() => { + hir::ItemKind::Struct(ref struct_def, _) if !struct_def.is_struct() => { Some(struct_def.id()) } _ => None @@ -454,13 +454,13 @@ struct DeadVisitor<'a, 'tcx: 'a> { impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { fn should_warn_about_item(&mut self, item: &hir::Item) -> bool { let should_warn = match item.node { - hir::ItemStatic(..) - | hir::ItemConst(..) - | hir::ItemFn(..) - | hir::ItemTy(..) - | hir::ItemEnum(..) - | hir::ItemStruct(..) - | hir::ItemUnion(..) => true, + hir::ItemKind::Static(..) + | hir::ItemKind::Const(..) + | hir::ItemKind::Fn(..) + | hir::ItemKind::Ty(..) + | hir::ItemKind::Enum(..) + | hir::ItemKind::Struct(..) + | hir::ItemKind::Union(..) => true, _ => false }; let ctor_id = get_struct_ctor_id(item); @@ -554,13 +554,13 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { // For items that have a definition with a signature followed by a // block, point only at the signature. let span = match item.node { - hir::ItemFn(..) | - hir::ItemMod(..) | - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemTrait(..) | - hir::ItemImpl(..) => self.tcx.sess.codemap().def_span(item.span), + hir::ItemKind::Fn(..) | + hir::ItemKind::Mod(..) | + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Trait(..) | + hir::ItemKind::Impl(..) => self.tcx.sess.codemap().def_span(item.span), _ => item.span, }; self.warn_dead_code( diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index ebc79646662..feeb508d676 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -16,7 +16,7 @@ use syntax::ast::NodeId; use syntax::attr; use syntax::entry::EntryPointType; use syntax_pos::Span; -use hir::{Item, ItemFn, ImplItem, TraitItem}; +use hir::{Item, ItemKind, ImplItem, TraitItem}; use hir::itemlikevisit::ItemLikeVisitor; struct EntryContext<'a, 'tcx: 'a> { @@ -91,7 +91,7 @@ pub fn find_entry_point(session: &Session, // them in sync. fn entry_point_type(item: &Item, at_root: bool) -> EntryPointType { match item.node { - ItemFn(..) => { + ItemKind::Fn(..) => { if attr::contains_name(&item.attrs, "start") { EntryPointType::Start } else if attr::contains_name(&item.attrs, "main") { diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 5c1a896e946..13b1660a7d5 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -58,8 +58,8 @@ fn item_might_be_inlined(tcx: TyCtxt<'a, 'tcx, 'tcx>, } match item.node { - hir::ItemImpl(..) | - hir::ItemFn(..) => { + hir::ItemKind::Impl(..) | + hir::ItemKind::Fn(..) => { let generics = tcx.generics_of(tcx.hir.local_def_id(item.id)); generics_require_inlining(generics) } @@ -171,7 +171,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { match self.tcx.hir.find(node_id) { Some(hir_map::NodeItem(item)) => { match item.node { - hir::ItemFn(..) => + hir::ItemKind::Fn(..) => item_might_be_inlined(self.tcx, &item, self.tcx.codegen_fn_attrs(def_id)), _ => false, } @@ -202,7 +202,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // does too. let impl_node_id = self.tcx.hir.as_local_node_id(impl_did).unwrap(); match self.tcx.hir.expect_item(impl_node_id).node { - hir::ItemImpl(..) => { + hir::ItemKind::Impl(..) => { let generics = self.tcx.generics_of(impl_did); generics_require_inlining(&generics) } @@ -238,7 +238,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // If we are building an executable, only explicitly extern // types need to be exported. if let hir_map::NodeItem(item) = *node { - let reachable = if let hir::ItemFn(_, header, ..) = item.node { + let reachable = if let hir::ItemKind::Fn(_, header, ..) = item.node { header.abi != Abi::Rust } else { false @@ -260,7 +260,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { match *node { hir_map::NodeItem(item) => { match item.node { - hir::ItemFn(.., body) => { + hir::ItemKind::Fn(.., body) => { let def_id = self.tcx.hir.local_def_id(item.id); if item_might_be_inlined(self.tcx, &item, @@ -272,20 +272,20 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // Reachable constants will be inlined into other crates // unconditionally, so we need to make sure that their // contents are also reachable. - hir::ItemConst(_, init) => { + hir::ItemKind::Const(_, init) => { self.visit_nested_body(init); } // These are normal, nothing reachable about these // inherently and their children are already in the // worklist, as determined by the privacy pass - hir::ItemExternCrate(_) | hir::ItemUse(..) | - hir::ItemExistential(..) | - hir::ItemTy(..) | hir::ItemStatic(..) | - hir::ItemMod(..) | hir::ItemForeignMod(..) | - hir::ItemImpl(..) | hir::ItemTrait(..) | hir::ItemTraitAlias(..) | - hir::ItemStruct(..) | hir::ItemEnum(..) | - hir::ItemUnion(..) | hir::ItemGlobalAsm(..) => {} + hir::ItemKind::ExternCrate(_) | hir::ItemKind::Use(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::Ty(..) | hir::ItemKind::Static(..) | + hir::ItemKind::Mod(..) | hir::ItemKind::ForeignMod(..) | + hir::ItemKind::Impl(..) | hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..) | + hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..) | + hir::ItemKind::Union(..) | hir::ItemKind::GlobalAsm(..) => {} } } hir_map::NodeTraitItem(trait_method) => { @@ -356,7 +356,7 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, } // We need only trait impls here, not inherent impls, and only non-exported ones - if let hir::ItemImpl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.node { + if let hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.node { if !self.access_levels.is_reachable(item.id) { for impl_item_ref in impl_item_refs { self.worklist.push(impl_item_ref.id.node_id); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 40dd51cf5b9..7953774856f 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -476,21 +476,21 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { match item.node { - hir::ItemFn(ref decl, _, ref generics, _) => { + hir::ItemKind::Fn(ref decl, _, ref generics, _) => { self.visit_early_late(None, decl, generics, |this| { intravisit::walk_item(this, item); }); } - hir::ItemExternCrate(_) - | hir::ItemUse(..) - | hir::ItemMod(..) - | hir::ItemForeignMod(..) - | hir::ItemGlobalAsm(..) => { + hir::ItemKind::ExternCrate(_) + | hir::ItemKind::Use(..) + | hir::ItemKind::Mod(..) + | hir::ItemKind::ForeignMod(..) + | hir::ItemKind::GlobalAsm(..) => { // These sorts of items have no lifetime parameters at all. intravisit::walk_item(self, item); } - hir::ItemStatic(..) | hir::ItemConst(..) => { + hir::ItemKind::Static(..) | hir::ItemKind::Const(..) => { // No lifetime parameters, but implied 'static. let scope = Scope::Elision { elide: Elide::Exact(Region::Static), @@ -498,27 +498,27 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { }; self.with(scope, |_, this| intravisit::walk_item(this, item)); } - hir::ItemExistential(hir::ExistTy { impl_trait_fn: Some(_), .. }) => { + hir::ItemKind::Existential(hir::ExistTy { impl_trait_fn: Some(_), .. }) => { // currently existential type declarations are just generated from impl Trait // items. doing anything on this node is irrelevant, as we currently don't need // it. } - hir::ItemTy(_, ref generics) - | hir::ItemExistential(hir::ExistTy { impl_trait_fn: None, ref generics, .. }) - | hir::ItemEnum(_, ref generics) - | hir::ItemStruct(_, ref generics) - | hir::ItemUnion(_, ref generics) - | hir::ItemTrait(_, _, ref generics, ..) - | hir::ItemTraitAlias(ref generics, ..) - | hir::ItemImpl(_, _, _, ref generics, ..) => { + hir::ItemKind::Ty(_, ref generics) + | hir::ItemKind::Existential(hir::ExistTy { impl_trait_fn: None, ref generics, .. }) + | hir::ItemKind::Enum(_, ref generics) + | hir::ItemKind::Struct(_, ref generics) + | hir::ItemKind::Union(_, ref generics) + | hir::ItemKind::Trait(_, _, ref generics, ..) + | hir::ItemKind::TraitAlias(ref generics, ..) + | hir::ItemKind::Impl(_, _, _, ref generics, ..) => { // Impls permit `'_` to be used and it is equivalent to "some fresh lifetime name". // This is not true for other kinds of items.x let track_lifetime_uses = match item.node { - hir::ItemImpl(..) => true, + hir::ItemKind::Impl(..) => true, _ => false, }; // These kinds of items have only early bound lifetime parameters. - let mut index = if let hir::ItemTrait(..) = item.node { + let mut index = if let hir::ItemKind::Trait(..) = item.node { 1 // Self comes before lifetimes } else { 0 @@ -675,7 +675,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { // ^ ^ this gets resolved in the scope of // the exist_ty generics let (generics, bounds) = match self.tcx.hir.expect_item(id).node { - hir::ItemExistential(hir::ExistTy{ ref generics, ref bounds, .. }) => ( + hir::ItemKind::Existential(hir::ExistTy{ ref generics, ref bounds, .. }) => ( generics, bounds, ), @@ -1208,11 +1208,11 @@ fn compute_object_lifetime_defaults( let mut map = NodeMap(); for item in tcx.hir.krate().items.values() { match item.node { - hir::ItemStruct(_, ref generics) - | hir::ItemUnion(_, ref generics) - | hir::ItemEnum(_, ref generics) - | hir::ItemTy(_, ref generics) - | hir::ItemTrait(_, _, ref generics, ..) => { + hir::ItemKind::Struct(_, ref generics) + | hir::ItemKind::Union(_, ref generics) + | hir::ItemKind::Enum(_, ref generics) + | hir::ItemKind::Ty(_, ref generics) + | hir::ItemKind::Trait(_, _, ref generics, ..) => { let result = object_lifetime_defaults_for_item(tcx, generics); // Debugging aid. @@ -1485,12 +1485,12 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { let mut index = 0; if let Some(parent_id) = parent_id { let parent = self.tcx.hir.expect_item(parent_id); - if let hir::ItemTrait(..) = parent.node { + if let hir::ItemKind::Trait(..) = parent.node { index += 1; // Self comes first. } match parent.node { - hir::ItemTrait(_, _, ref generics, ..) - | hir::ItemImpl(_, _, _, ref generics, ..) => { + hir::ItemKind::Trait(_, _, ref generics, ..) + | hir::ItemKind::Impl(_, _, _, ref generics, ..) => { index += generics.params.len() as u32; } _ => {} @@ -1609,7 +1609,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { let fn_id = self.tcx.hir.body_owner(body_id); match self.tcx.hir.get(fn_id) { hir::map::NodeItem(&hir::Item { - node: hir::ItemFn(..), + node: hir::ItemKind::Fn(..), .. }) | hir::map::NodeTraitItem(&hir::TraitItem { @@ -1834,7 +1834,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { let body = match self.tcx.hir.get(parent) { // `fn` definitions and methods. hir::map::NodeItem(&hir::Item { - node: hir::ItemFn(.., body), + node: hir::ItemKind::Fn(.., body), .. }) => Some(body), @@ -1847,7 +1847,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { .expect_item(self.tcx.hir.get_parent(parent)) .node { - hir::ItemTrait(.., ref trait_items) => { + hir::ItemKind::Trait(.., ref trait_items) => { assoc_item_kind = trait_items .iter() .find(|ti| ti.id.node_id == parent) @@ -1870,7 +1870,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { .expect_item(self.tcx.hir.get_parent(parent)) .node { - hir::ItemImpl(.., ref self_ty, ref impl_items) => { + hir::ItemKind::Impl(.., ref self_ty, ref impl_items) => { impl_self = Some(self_ty); assoc_item_kind = impl_items .iter() diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 9bf5c4d72b7..fdcae38fc6a 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -263,14 +263,14 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { // they don't have their own stability. They still can be annotated as unstable // and propagate this unstability to children, but this annotation is completely // optional. They inherit stability from their parents when unannotated. - hir::ItemImpl(.., None, _, _) | hir::ItemForeignMod(..) => { + hir::ItemKind::Impl(.., None, _, _) | hir::ItemKind::ForeignMod(..) => { self.in_trait_impl = false; kind = AnnotationKind::Container; } - hir::ItemImpl(.., Some(_), _, _) => { + hir::ItemKind::Impl(.., Some(_), _, _) => { self.in_trait_impl = true; } - hir::ItemStruct(ref sd, _) => { + hir::ItemKind::Struct(ref sd, _) => { if !sd.is_struct() { self.annotate(sd.id(), &i.attrs, i.span, AnnotationKind::Required, |_| {}) } @@ -353,7 +353,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> { // they don't have their own stability. They still can be annotated as unstable // and propagate this unstability to children, but this annotation is completely // optional. They inherit stability from their parents when unannotated. - hir::ItemImpl(.., None, _, _) | hir::ItemForeignMod(..) => {} + hir::ItemKind::Impl(.., None, _, _) | hir::ItemKind::ForeignMod(..) => {} _ => self.check_missing_stability(i.id, i.span) } @@ -723,7 +723,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { match item.node { - hir::ItemExternCrate(_) => { + hir::ItemKind::ExternCrate(_) => { // compiler-generated `extern crate` items have a dummy span. if item.span.is_dummy() { return } @@ -739,7 +739,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { // For implementations of traits, check the stability of each item // individually as it's possible to have a stable trait with unstable // items. - hir::ItemImpl(.., Some(ref t), _, ref impl_item_refs) => { + hir::ItemKind::Impl(.., Some(ref t), _, ref impl_item_refs) => { if let Def::Trait(trait_did) = t.path.def { for impl_item_ref in impl_item_refs { let impl_item = self.tcx.hir.impl_item(impl_item_ref.id); @@ -756,7 +756,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { // There's no good place to insert stability check for non-Copy unions, // so semi-randomly perform it here in stability.rs - hir::ItemUnion(..) if !self.tcx.features().untagged_unions => { + hir::ItemKind::Union(..) if !self.tcx.features().untagged_unions => { let def_id = self.tcx.hir.local_def_id(item.id); let adt_def = self.tcx.adt_def(def_id); let ty = self.tcx.type_of(def_id); diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 9fd2748e5ea..df26ac67060 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -955,7 +955,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } hir::map::NodeItem(&hir::Item { span, - node: hir::ItemFn(ref decl, ..), + node: hir::ItemKind::Fn(ref decl, ..), .. }) | hir::map::NodeImplItem(&hir::ImplItem { diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index 684022f8e8a..875c7199f6d 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -534,7 +534,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { match self.hir.as_local_node_id(node_item_def_id) { Some(node_id) => { let item = self.hir.expect_item(node_id); - if let hir::ItemImpl(_, _, defaultness, ..) = item.node { + if let hir::ItemKind::Impl(_, _, defaultness, ..) = item.node { defaultness.is_default() } else { false diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index bbfcfb79890..5aa6542a027 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2757,7 +2757,7 @@ fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) let parent_def_id = tcx.hir.local_def_id(parent_id); let parent_item = tcx.hir.expect_item(parent_id); match parent_item.node { - hir::ItemImpl(.., ref impl_item_refs) => { + hir::ItemKind::Impl(.., ref impl_item_refs) => { if let Some(impl_item_ref) = impl_item_refs.iter().find(|i| i.id.node_id == id) { let assoc_item = tcx.associated_item_from_impl_item_ref(parent_def_id, impl_item_ref); @@ -2766,7 +2766,7 @@ fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) } } - hir::ItemTrait(.., ref trait_item_refs) => { + hir::ItemKind::Trait(.., ref trait_item_refs) => { if let Some(trait_item_ref) = trait_item_refs.iter().find(|i| i.id.node_id == id) { let assoc_item = tcx.associated_item_from_trait_item_ref(parent_def_id, &parent_item.vis, @@ -2815,19 +2815,19 @@ fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let id = tcx.hir.as_local_node_id(def_id).unwrap(); let item = tcx.hir.expect_item(id); let vec: Vec<_> = match item.node { - hir::ItemTrait(.., ref trait_item_refs) => { + hir::ItemKind::Trait(.., ref trait_item_refs) => { trait_item_refs.iter() .map(|trait_item_ref| trait_item_ref.id) .map(|id| tcx.hir.local_def_id(id.node_id)) .collect() } - hir::ItemImpl(.., ref impl_item_refs) => { + hir::ItemKind::Impl(.., ref impl_item_refs) => { impl_item_refs.iter() .map(|impl_item_ref| impl_item_ref.id) .map(|id| tcx.hir.local_def_id(id.node_id)) .collect() } - hir::ItemTraitAlias(..) => vec![], + hir::ItemKind::TraitAlias(..) => vec![], _ => span_bug!(item.span, "associated_item_def_ids: not impl or trait") }; Lrc::new(vec) diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index d12cce5ac4d..d5425aff6ba 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -605,7 +605,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { if let Some(node) = self.hir.get_if_local(def_id) { match node { Node::NodeItem(&hir::Item { - node: hir::ItemStatic(_, mutbl, _), .. + node: hir::ItemKind::Static(_, mutbl, _), .. }) => Some(mutbl), Node::NodeForeignItem(&hir::ForeignItem { node: hir::ForeignItemKind::Static(_, is_mutbl), .. diff --git a/src/librustc_codegen_llvm/back/symbol_export.rs b/src/librustc_codegen_llvm/back/symbol_export.rs index 28e76a80513..94357f34849 100644 --- a/src/librustc_codegen_llvm/back/symbol_export.rs +++ b/src/librustc_codegen_llvm/back/symbol_export.rs @@ -105,11 +105,11 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // Only consider nodes that actually have exported symbols. hir::map::NodeItem(&hir::Item { - node: hir::ItemStatic(..), + node: hir::ItemKind::Static(..), .. }) | hir::map::NodeItem(&hir::Item { - node: hir::ItemFn(..), .. + node: hir::ItemKind::Fn(..), .. }) | hir::map::NodeImplItem(&hir::ImplItem { node: hir::ImplItemKind::Method(..), diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index 81e51e59d92..6e3096d4cd5 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -125,7 +125,7 @@ pub fn get_static(cx: &CodegenCx, def_id: DefId) -> ValueRef { let llty = cx.layout_of(ty).llvm_type(cx); let (g, attrs) = match cx.tcx.hir.get(id) { hir_map::NodeItem(&hir::Item { - ref attrs, span, node: hir::ItemStatic(..), .. + ref attrs, span, node: hir::ItemKind::Static(..), .. }) => { if declare::get_declared_value(cx, &sym[..]).is_some() { span_bug!(span, "Conflicting symbol names for static?"); diff --git a/src/librustc_codegen_llvm/mono_item.rs b/src/librustc_codegen_llvm/mono_item.rs index e142a7d9c1c..b512a6f1bb4 100644 --- a/src/librustc_codegen_llvm/mono_item.rs +++ b/src/librustc_codegen_llvm/mono_item.rs @@ -60,7 +60,7 @@ pub trait MonoItemExt<'a, 'tcx>: fmt::Debug + BaseMonoItemExt<'a, 'tcx> { } MonoItem::GlobalAsm(node_id) => { let item = cx.tcx.hir.expect_item(node_id); - if let hir::ItemGlobalAsm(ref ga) = item.node { + if let hir::ItemKind::GlobalAsm(ref ga) = item.node { asm::codegen_global_asm(cx, ga); } else { span_bug!(item.span, "Mismatch between hir::Item type and MonoItem type") diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 9808e289f3b..f082d03234a 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -249,24 +249,24 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> { } return match it.node { - hir::ItemUse(..) | - hir::ItemExternCrate(..) | - hir::ItemConst(..) | - hir::ItemStatic(..) | - hir::ItemFn(..) | - hir::ItemForeignMod(..) | - hir::ItemGlobalAsm(..) | - hir::ItemExistential(..) | - hir::ItemTy(..) => None, - - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemTrait(..) | - hir::ItemTraitAlias(..) | - hir::ItemImpl(..) => None, - - hir::ItemMod(ref m) => search_mod(this, m, idx, names), + hir::ItemKind::Use(..) | + hir::ItemKind::ExternCrate(..) | + hir::ItemKind::Const(..) | + hir::ItemKind::Static(..) | + hir::ItemKind::Fn(..) | + hir::ItemKind::ForeignMod(..) | + hir::ItemKind::GlobalAsm(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::Ty(..) => None, + + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Trait(..) | + hir::ItemKind::TraitAlias(..) | + hir::ItemKind::Impl(..) => None, + + hir::ItemKind::Mod(ref m) => search_mod(this, m, idx, names), }; } } diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index eeb87e41757..51409a0d283 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -29,7 +29,7 @@ use std::iter::FromIterator; use std::vec::Vec; use rustc::dep_graph::{DepNode, label_strs}; use rustc::hir; -use rustc::hir::{Item_ as HirItem, ImplItemKind, TraitItemKind}; +use rustc::hir::{ItemKind as HirItem, ImplItemKind, TraitItemKind}; use rustc::hir::map::Node as HirNode; use rustc::hir::def_id::DefId; use rustc::hir::itemlikevisit::ItemLikeVisitor; @@ -342,40 +342,40 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> { // FIXME(michaelwoerister): do commented out ones // // An `extern crate` item, with optional original crate name, - // HirItem::ItemExternCrate(..), // intentionally no assertions + // HirItem::ExternCrate(..), // intentionally no assertions // // `use foo::bar::*;` or `use foo::bar::baz as quux;` - // HirItem::ItemUse(..), // intentionally no assertions + // HirItem::Use(..), // intentionally no assertions // A `static` item - HirItem::ItemStatic(..) => ("ItemStatic", LABELS_CONST), + HirItem::Static(..) => ("ItemStatic", LABELS_CONST), // A `const` item - HirItem::ItemConst(..) => ("ItemConst", LABELS_CONST), + HirItem::Const(..) => ("ItemConst", LABELS_CONST), // A function declaration - HirItem::ItemFn(..) => ("ItemFn", LABELS_FN), + HirItem::Fn(..) => ("ItemFn", LABELS_FN), // // A module - HirItem::ItemMod(..) =>("ItemMod", LABELS_HIR_ONLY), + HirItem::Mod(..) =>("ItemMod", LABELS_HIR_ONLY), // // An external module - HirItem::ItemForeignMod(..) => ("ItemForeignMod", LABELS_HIR_ONLY), + HirItem::ForeignMod(..) => ("ItemForeignMod", LABELS_HIR_ONLY), // Module-level inline assembly (from global_asm!) - HirItem::ItemGlobalAsm(..) => ("ItemGlobalAsm", LABELS_HIR_ONLY), + HirItem::GlobalAsm(..) => ("ItemGlobalAsm", LABELS_HIR_ONLY), // A type alias, e.g. `type Foo = Bar<u8>` - HirItem::ItemTy(..) => ("ItemTy", LABELS_HIR_ONLY), + HirItem::Ty(..) => ("ItemTy", LABELS_HIR_ONLY), // An enum definition, e.g. `enum Foo<A, B> {C<A>, D<B>}` - HirItem::ItemEnum(..) => ("ItemEnum", LABELS_ADT), + HirItem::Enum(..) => ("ItemEnum", LABELS_ADT), // A struct definition, e.g. `struct Foo<A> {x: A}` - HirItem::ItemStruct(..) => ("ItemStruct", LABELS_ADT), + HirItem::Struct(..) => ("ItemStruct", LABELS_ADT), // A union definition, e.g. `union Foo<A, B> {x: A, y: B}` - HirItem::ItemUnion(..) => ("ItemUnion", LABELS_ADT), + HirItem::Union(..) => ("ItemUnion", LABELS_ADT), // Represents a Trait Declaration // FIXME(michaelwoerister): trait declaration is buggy because sometimes some of @@ -391,10 +391,10 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> { // However, this did not seem to work effectively and more bugs were hit. // Nebie @vitiral gave up :) // - //HirItem::ItemTrait(..) => ("ItemTrait", LABELS_TRAIT), + //HirItem::Trait(..) => ("ItemTrait", LABELS_TRAIT), // An implementation, eg `impl<A> Trait for Foo { .. }` - HirItem::ItemImpl(..) => ("ItemImpl", LABELS_IMPL), + HirItem::Impl(..) => ("ItemImpl", LABELS_IMPL), _ => self.tcx.sess.span_fatal( attr.span, diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/bad_style.rs index 6bc364b7261..fd5a152311d 100644 --- a/src/librustc_lint/bad_style.rs +++ b/src/librustc_lint/bad_style.rs @@ -133,11 +133,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCamelCaseTypes { } match it.node { - hir::ItemTy(..) | - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) => self.check_case(cx, "type", it.name, it.span), - hir::ItemTrait(..) => self.check_case(cx, "trait", it.name, it.span), + hir::ItemKind::Ty(..) | + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) => self.check_case(cx, "type", it.name, it.span), + hir::ItemKind::Trait(..) => self.check_case(cx, "trait", it.name, it.span), _ => (), } } @@ -296,7 +296,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase { } fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { - if let hir::ItemMod(_) = it.node { + if let hir::ItemKind::Mod(_) = it.node { self.check_snake_case(cx, "module", &it.name.as_str(), Some(it.span)); } } @@ -369,13 +369,13 @@ impl LintPass for NonUpperCaseGlobals { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { match it.node { - hir::ItemStatic(..) => { + hir::ItemKind::Static(..) => { if attr::find_by_name(&it.attrs, "no_mangle").is_some() { return; } NonUpperCaseGlobals::check_upper_case(cx, "static variable", it.name, it.span); } - hir::ItemConst(..) => { + hir::ItemKind::Const(..) => { NonUpperCaseGlobals::check_upper_case(cx, "constant", it.name, it.span); } _ => {} diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 0ebb1a2bca8..8a674449880 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -120,11 +120,11 @@ impl LintPass for BoxPointers { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { match it.node { - hir::ItemFn(..) | - hir::ItemTy(..) | - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) => { + hir::ItemKind::Fn(..) | + hir::ItemKind::Ty(..) | + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) => { let def_id = cx.tcx.hir.local_def_id(it.id); self.check_heap_type(cx, it.span, cx.tcx.type_of(def_id)) } @@ -133,8 +133,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers { // If it's a struct, we also have to check the fields' types match it.node { - hir::ItemStruct(ref struct_def, _) | - hir::ItemUnion(ref struct_def, _) => { + hir::ItemKind::Struct(ref struct_def, _) | + hir::ItemKind::Union(ref struct_def, _) => { for struct_field in struct_def.fields() { let def_id = cx.tcx.hir.local_def_id(struct_field.id); self.check_heap_type(cx, struct_field.span, @@ -236,11 +236,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { match it.node { - hir::ItemTrait(_, hir::Unsafety::Unsafe, ..) => { + hir::ItemKind::Trait(_, hir::Unsafety::Unsafe, ..) => { self.report_unsafe(cx, it.span, "declaration of an `unsafe` trait") } - hir::ItemImpl(hir::Unsafety::Unsafe, ..) => { + hir::ItemKind::Impl(hir::Unsafety::Unsafe, ..) => { self.report_unsafe(cx, it.span, "implementation of an `unsafe` trait") } @@ -390,12 +390,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { let desc = match it.node { - hir::ItemFn(..) => "a function", - hir::ItemMod(..) => "a module", - hir::ItemEnum(..) => "an enum", - hir::ItemStruct(..) => "a struct", - hir::ItemUnion(..) => "a union", - hir::ItemTrait(.., ref trait_item_refs) => { + hir::ItemKind::Fn(..) => "a function", + hir::ItemKind::Mod(..) => "a module", + hir::ItemKind::Enum(..) => "an enum", + hir::ItemKind::Struct(..) => "a struct", + hir::ItemKind::Union(..) => "a union", + hir::ItemKind::Trait(.., ref trait_item_refs) => { // Issue #11592, traits are always considered exported, even when private. if let hir::VisibilityKind::Inherited = it.vis.node { self.private_traits.insert(it.id); @@ -406,8 +406,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { } "a trait" } - hir::ItemTy(..) => "a type alias", - hir::ItemImpl(.., Some(ref trait_ref), _, ref impl_item_refs) => { + hir::ItemKind::Ty(..) => "a type alias", + hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) => { // If the trait is private, add the impl items to private_traits so they don't get // reported for missing docs. let real_trait = trait_ref.path.def.def_id(); @@ -425,8 +425,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { } return; } - hir::ItemConst(..) => "a constant", - hir::ItemStatic(..) => "a static", + hir::ItemKind::Const(..) => "a constant", + hir::ItemKind::Static(..) => "a static", _ => return, }; @@ -509,21 +509,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations { return; } let (def, ty) = match item.node { - hir::ItemStruct(_, ref ast_generics) => { + hir::ItemKind::Struct(_, ref ast_generics) => { if !ast_generics.params.is_empty() { return; } let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id)); (def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[]))) } - hir::ItemUnion(_, ref ast_generics) => { + hir::ItemKind::Union(_, ref ast_generics) => { if !ast_generics.params.is_empty() { return; } let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id)); (def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[]))) } - hir::ItemEnum(_, ref ast_generics) => { + hir::ItemKind::Enum(_, ref ast_generics) => { if !ast_generics.params.is_empty() { return; } @@ -577,9 +577,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations { } match item.node { - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemEnum(..) => {} + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Enum(..) => {} _ => return, } @@ -1121,7 +1121,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary { } match it.node { - hir::ItemExternCrate(..) => (), + hir::ItemKind::ExternCrate(..) => (), _ => return, }; @@ -1203,7 +1203,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems { }; match it.node { - hir::ItemFn(.., ref generics, _) => { + hir::ItemKind::Fn(.., ref generics, _) => { if let Some(no_mangle_attr) = attr::find_by_name(&it.attrs, "no_mangle") { if attr::contains_name(&it.attrs, "linkage") { return; @@ -1232,7 +1232,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems { } } } - hir::ItemStatic(..) => { + hir::ItemKind::Static(..) => { if attr::contains_name(&it.attrs, "no_mangle") && !cx.access_levels.is_reachable(it.id) { let msg = "static is marked #[no_mangle], but not exported"; @@ -1241,7 +1241,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems { err.emit(); } } - hir::ItemConst(..) => { + hir::ItemKind::Const(..) => { if attr::contains_name(&it.attrs, "no_mangle") { // Const items do not refer to a particular location in memory, and therefore // don't have anything to attach a symbol to @@ -1369,7 +1369,7 @@ impl LintPass for UnionsWithDropFields { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields { fn check_item(&mut self, ctx: &LateContext, item: &hir::Item) { - if let hir::ItemUnion(ref vdata, _) = item.node { + if let hir::ItemKind::Union(ref vdata, _) = item.node { for field in vdata.fields() { let field_ty = ctx.tcx.type_of(ctx.tcx.hir.local_def_id(field.id)); if field_ty.needs_drop(ctx.tcx, ctx.param_env) { @@ -1523,7 +1523,7 @@ impl TypeAliasBounds { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds { fn check_item(&mut self, cx: &LateContext, item: &hir::Item) { let (ty, type_alias_generics) = match item.node { - hir::ItemTy(ref ty, ref generics) => (&*ty, generics), + hir::ItemKind::Ty(ref ty, ref generics) => (&*ty, generics), _ => return, }; let mut suggested_changing_assoc_types = false; @@ -1605,10 +1605,10 @@ impl<'a, 'tcx, 'v> hir::intravisit::Visitor<'v> for UnusedBrokenConstVisitor<'a, impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedBrokenConst { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { match it.node { - hir::ItemConst(_, body_id) => { + hir::ItemKind::Const(_, body_id) => { check_const(cx, body_id, "constant"); }, - hir::ItemTy(ref ty, _) => hir::intravisit::walk_ty( + hir::ItemKind::Ty(ref ty, _) => hir::intravisit::walk_ty( &mut UnusedBrokenConstVisitor(cx), ty ), @@ -1761,12 +1761,12 @@ impl LintPass for UnnameableTestFunctions { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnameableTestFunctions { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { match it.node { - hir::ItemFn(..) => { + hir::ItemKind::Fn(..) => { for attr in &it.attrs { if attr.name() == "test" { let parent = cx.tcx.hir.get_parent(it.id); match cx.tcx.hir.find(parent) { - Some(hir_map::NodeItem(hir::Item {node: hir::ItemMod(_), ..})) | + Some(hir_map::NodeItem(hir::Item {node: hir::ItemKind::Mod(_), ..})) | None => {} _ => { cx.struct_span_lint( diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 30cf9288c80..fd9378271a2 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -782,7 +782,7 @@ impl LintPass for ImproperCTypes { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { let mut vis = ImproperCTypesVisitor { cx: cx }; - if let hir::ItemForeignMod(ref nmod) = it.node { + if let hir::ItemKind::ForeignMod(ref nmod) = it.node { if nmod.abi != Abi::RustIntrinsic && nmod.abi != Abi::PlatformIntrinsic { for ni in &nmod.items { match ni.node { @@ -810,7 +810,7 @@ impl LintPass for VariantSizeDifferences { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { - if let hir::ItemEnum(ref enum_definition, _) = it.node { + if let hir::ItemKind::Enum(ref enum_definition, _) = it.node { let item_def_id = cx.tcx.hir.local_def_id(it.id); let generics = cx.tcx.generics_of(item_def_id); for param in &generics.params { diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 25bd2d09704..b9cb97ed7d0 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -1039,16 +1039,16 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { debug!("IsolatedEncoder::encode_info_for_item({:?})", def_id); let kind = match item.node { - hir::ItemStatic(_, hir::MutMutable, _) => EntryKind::MutStatic, - hir::ItemStatic(_, hir::MutImmutable, _) => EntryKind::ImmStatic, - hir::ItemConst(_, body_id) => { + hir::ItemKind::Static(_, hir::MutMutable, _) => EntryKind::MutStatic, + hir::ItemKind::Static(_, hir::MutImmutable, _) => EntryKind::ImmStatic, + hir::ItemKind::Const(_, body_id) => { let mir = tcx.at(item.span).mir_const_qualif(def_id).0; EntryKind::Const( self.const_qualif(mir, body_id), self.encode_rendered_const_for_body(body_id) ) } - hir::ItemFn(_, header, .., body) => { + hir::ItemKind::Fn(_, header, .., body) => { let data = FnData { constness: header.constness, arg_names: self.encode_fn_arg_names_for_body(body), @@ -1057,15 +1057,15 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { EntryKind::Fn(self.lazy(&data)) } - hir::ItemMod(ref m) => { + hir::ItemKind::Mod(ref m) => { return self.encode_info_for_mod(FromId(item.id, (m, &item.attrs, &item.vis))); } - hir::ItemForeignMod(_) => EntryKind::ForeignMod, - hir::ItemGlobalAsm(..) => EntryKind::GlobalAsm, - hir::ItemTy(..) => EntryKind::Type, - hir::ItemExistential(..) => EntryKind::Existential, - hir::ItemEnum(..) => EntryKind::Enum(get_repr_options(&tcx, def_id)), - hir::ItemStruct(ref struct_def, _) => { + hir::ItemKind::ForeignMod(_) => EntryKind::ForeignMod, + hir::ItemKind::GlobalAsm(..) => EntryKind::GlobalAsm, + hir::ItemKind::Ty(..) => EntryKind::Type, + hir::ItemKind::Existential(..) => EntryKind::Existential, + hir::ItemKind::Enum(..) => EntryKind::Enum(get_repr_options(&tcx, def_id)), + hir::ItemKind::Struct(ref struct_def, _) => { let variant = tcx.adt_def(def_id).non_enum_variant(); // Encode def_ids for each field and method @@ -1086,7 +1086,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { ctor_sig: None, }), repr_options) } - hir::ItemUnion(..) => { + hir::ItemKind::Union(..) => { let variant = tcx.adt_def(def_id).non_enum_variant(); let repr_options = get_repr_options(&tcx, def_id); @@ -1097,7 +1097,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { ctor_sig: None, }), repr_options) } - hir::ItemImpl(_, polarity, defaultness, ..) => { + hir::ItemKind::Impl(_, polarity, defaultness, ..) => { let trait_ref = tcx.impl_trait_ref(def_id); let parent = if let Some(trait_ref) = trait_ref { let trait_def = tcx.trait_def(trait_ref.def_id); @@ -1132,7 +1132,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { EntryKind::Impl(self.lazy(&data)) } - hir::ItemTrait(..) => { + hir::ItemKind::Trait(..) => { let trait_def = tcx.trait_def(def_id); let data = TraitData { unsafety: trait_def.unsafety, @@ -1143,9 +1143,9 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { EntryKind::Trait(self.lazy(&data)) } - hir::ItemExternCrate(_) | - hir::ItemTraitAlias(..) | - hir::ItemUse(..) => bug!("cannot encode info for item {:?}", item), + hir::ItemKind::ExternCrate(_) | + hir::ItemKind::TraitAlias(..) | + hir::ItemKind::Use(..) => bug!("cannot encode info for item {:?}", item), }; Entry { @@ -1154,28 +1154,28 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { span: self.lazy(&item.span), attributes: self.encode_attributes(&item.attrs), children: match item.node { - hir::ItemForeignMod(ref fm) => { + hir::ItemKind::ForeignMod(ref fm) => { self.lazy_seq(fm.items .iter() .map(|foreign_item| tcx.hir.local_def_id(foreign_item.id).index)) } - hir::ItemEnum(..) => { + hir::ItemKind::Enum(..) => { let def = self.tcx.adt_def(def_id); self.lazy_seq(def.variants.iter().map(|v| { assert!(v.did.is_local()); v.did.index })) } - hir::ItemStruct(..) | - hir::ItemUnion(..) => { + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) => { let def = self.tcx.adt_def(def_id); self.lazy_seq(def.non_enum_variant().fields.iter().map(|f| { assert!(f.did.is_local()); f.did.index })) } - hir::ItemImpl(..) | - hir::ItemTrait(..) => { + hir::ItemKind::Impl(..) | + hir::ItemKind::Trait(..) => { self.lazy_seq(tcx.associated_item_def_ids(def_id).iter().map(|&def_id| { assert!(def_id.is_local()); def_id.index @@ -1187,49 +1187,49 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { deprecation: self.encode_deprecation(def_id), ty: match item.node { - hir::ItemStatic(..) | - hir::ItemConst(..) | - hir::ItemFn(..) | - hir::ItemTy(..) | - hir::ItemExistential(..) | - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemImpl(..) => Some(self.encode_item_type(def_id)), + hir::ItemKind::Static(..) | + hir::ItemKind::Const(..) | + hir::ItemKind::Fn(..) | + hir::ItemKind::Ty(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Impl(..) => Some(self.encode_item_type(def_id)), _ => None, }, inherent_impls: self.encode_inherent_implementations(def_id), variances: match item.node { - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemFn(..) => self.encode_variances_of(def_id), + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Fn(..) => self.encode_variances_of(def_id), _ => LazySeq::empty(), }, generics: match item.node { - hir::ItemStatic(..) | - hir::ItemConst(..) | - hir::ItemFn(..) | - hir::ItemTy(..) | - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemImpl(..) | - hir::ItemExistential(..) | - hir::ItemTrait(..) => Some(self.encode_generics(def_id)), + hir::ItemKind::Static(..) | + hir::ItemKind::Const(..) | + hir::ItemKind::Fn(..) | + hir::ItemKind::Ty(..) | + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Impl(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::Trait(..) => Some(self.encode_generics(def_id)), _ => None, }, predicates: match item.node { - hir::ItemStatic(..) | - hir::ItemConst(..) | - hir::ItemFn(..) | - hir::ItemTy(..) | - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemImpl(..) | - hir::ItemExistential(..) | - hir::ItemTrait(..) => Some(self.encode_predicates(def_id)), + hir::ItemKind::Static(..) | + hir::ItemKind::Const(..) | + hir::ItemKind::Fn(..) | + hir::ItemKind::Ty(..) | + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Impl(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::Trait(..) => Some(self.encode_predicates(def_id)), _ => None, }, @@ -1239,16 +1239,16 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { // hack. (No reason not to expand it in the future if // necessary.) predicates_defined_on: match item.node { - hir::ItemTrait(..) => Some(self.encode_predicates_defined_on(def_id)), + hir::ItemKind::Trait(..) => Some(self.encode_predicates_defined_on(def_id)), _ => None, // not *wrong* for other kinds of items, but not needed }, mir: match item.node { - hir::ItemStatic(..) => { + hir::ItemKind::Static(..) => { self.encode_optimized_mir(def_id) } - hir::ItemConst(..) => self.encode_optimized_mir(def_id), - hir::ItemFn(_, header, ..) => { + hir::ItemKind::Const(..) => self.encode_optimized_mir(def_id), + hir::ItemKind::Fn(_, header, ..) => { let generics = tcx.generics_of(def_id); let has_types = generics.params.iter().any(|param| match param.kind { ty::GenericParamDefKind::Type { .. } => true, @@ -1614,8 +1614,8 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> { intravisit::walk_item(self, item); let def_id = self.index.tcx.hir.local_def_id(item.id); match item.node { - hir::ItemExternCrate(_) | - hir::ItemUse(..) => (), // ignore these + hir::ItemKind::ExternCrate(_) | + hir::ItemKind::Use(..) => (), // ignore these _ => self.index.record(def_id, IsolatedEncoder::encode_info_for_item, (def_id, item)), } self.index.encode_addl_info_for_item(item); @@ -1703,20 +1703,20 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { fn encode_addl_info_for_item(&mut self, item: &hir::Item) { let def_id = self.tcx.hir.local_def_id(item.id); match item.node { - hir::ItemStatic(..) | - hir::ItemConst(..) | - hir::ItemFn(..) | - hir::ItemMod(..) | - hir::ItemForeignMod(..) | - hir::ItemGlobalAsm(..) | - hir::ItemExternCrate(..) | - hir::ItemUse(..) | - hir::ItemTy(..) | - hir::ItemExistential(..) | - hir::ItemTraitAlias(..) => { + hir::ItemKind::Static(..) | + hir::ItemKind::Const(..) | + hir::ItemKind::Fn(..) | + hir::ItemKind::Mod(..) | + hir::ItemKind::ForeignMod(..) | + hir::ItemKind::GlobalAsm(..) | + hir::ItemKind::ExternCrate(..) | + hir::ItemKind::Use(..) | + hir::ItemKind::Ty(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::TraitAlias(..) => { // no sub-item recording needed in these cases } - hir::ItemEnum(..) => { + hir::ItemKind::Enum(..) => { self.encode_fields(def_id); let def = self.tcx.adt_def(def_id); @@ -1726,7 +1726,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { (def_id, Untracked(i))); } } - hir::ItemStruct(ref struct_def, _) => { + hir::ItemKind::Struct(ref struct_def, _) => { self.encode_fields(def_id); // If the struct has a constructor, encode it. @@ -1737,17 +1737,17 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { (def_id, ctor_def_id)); } } - hir::ItemUnion(..) => { + hir::ItemKind::Union(..) => { self.encode_fields(def_id); } - hir::ItemImpl(..) => { + hir::ItemKind::Impl(..) => { for &trait_item_def_id in self.tcx.associated_item_def_ids(def_id).iter() { self.record(trait_item_def_id, IsolatedEncoder::encode_info_for_impl_item, trait_item_def_id); } } - hir::ItemTrait(..) => { + hir::ItemKind::Trait(..) => { for &item_def_id in self.tcx.associated_item_def_ids(def_id).iter() { self.record(item_def_id, IsolatedEncoder::encode_info_for_trait_item, @@ -1765,7 +1765,7 @@ struct ImplVisitor<'a, 'tcx: 'a> { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { - if let hir::ItemImpl(..) = item.node { + if let hir::ItemKind::Impl(..) = item.node { let impl_id = self.tcx.hir.local_def_id(item.id); if let Some(trait_ref) = self.tcx.impl_trait_ref(impl_id) { self.impls diff --git a/src/librustc_metadata/foreign_modules.rs b/src/librustc_metadata/foreign_modules.rs index c44d891b7f3..e96d56fb388 100644 --- a/src/librustc_metadata/foreign_modules.rs +++ b/src/librustc_metadata/foreign_modules.rs @@ -30,7 +30,7 @@ struct Collector<'a, 'tcx: 'a> { impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { fn visit_item(&mut self, it: &'tcx hir::Item) { let fm = match it.node { - hir::ItemForeignMod(ref fm) => fm, + hir::ItemKind::ForeignMod(ref fm) => fm, _ => return, }; diff --git a/src/librustc_metadata/link_args.rs b/src/librustc_metadata/link_args.rs index b699885b0eb..008e1e363ff 100644 --- a/src/librustc_metadata/link_args.rs +++ b/src/librustc_metadata/link_args.rs @@ -37,7 +37,7 @@ struct Collector { impl<'tcx> ItemLikeVisitor<'tcx> for Collector { fn visit_item(&mut self, it: &'tcx hir::Item) { let fm = match it.node { - hir::ItemForeignMod(ref fm) => fm, + hir::ItemKind::ForeignMod(ref fm) => fm, _ => return, }; if fm.abi == Abi::Rust || diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index 70b8c7b11fd..327b2abc4d3 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -45,7 +45,7 @@ struct Collector<'a, 'tcx: 'a> { impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { fn visit_item(&mut self, it: &'tcx hir::Item) { let fm = match it.node { - hir::ItemForeignMod(ref fm) => fm, + hir::ItemKind::ForeignMod(ref fm) => fm, _ => return, }; diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index ce917b8ca55..a2d620db924 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -945,18 +945,18 @@ struct RootCollector<'b, 'a: 'b, 'tcx: 'a + 'b> { impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { fn visit_item(&mut self, item: &'v hir::Item) { match item.node { - hir::ItemExternCrate(..) | - hir::ItemUse(..) | - hir::ItemForeignMod(..) | - hir::ItemTy(..) | - hir::ItemTrait(..) | - hir::ItemTraitAlias(..) | - hir::ItemExistential(..) | - hir::ItemMod(..) => { + hir::ItemKind::ExternCrate(..) | + hir::ItemKind::Use(..) | + hir::ItemKind::ForeignMod(..) | + hir::ItemKind::Ty(..) | + hir::ItemKind::Trait(..) | + hir::ItemKind::TraitAlias(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::Mod(..) => { // Nothing to do, just keep recursing... } - hir::ItemImpl(..) => { + hir::ItemKind::Impl(..) => { if self.mode == MonoItemCollectionMode::Eager { create_mono_items_for_default_impls(self.tcx, item, @@ -964,9 +964,9 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { } } - hir::ItemEnum(_, ref generics) | - hir::ItemStruct(_, ref generics) | - hir::ItemUnion(_, ref generics) => { + hir::ItemKind::Enum(_, ref generics) | + hir::ItemKind::Struct(_, ref generics) | + hir::ItemKind::Union(_, ref generics) => { if generics.params.is_empty() { if self.mode == MonoItemCollectionMode::Eager { let def_id = self.tcx.hir.local_def_id(item.id); @@ -978,19 +978,19 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { } } } - hir::ItemGlobalAsm(..) => { - debug!("RootCollector: ItemGlobalAsm({})", + hir::ItemKind::GlobalAsm(..) => { + debug!("RootCollector: ItemKind::GlobalAsm({})", def_id_to_string(self.tcx, self.tcx.hir.local_def_id(item.id))); self.output.push(MonoItem::GlobalAsm(item.id)); } - hir::ItemStatic(..) => { + hir::ItemKind::Static(..) => { let def_id = self.tcx.hir.local_def_id(item.id); - debug!("RootCollector: ItemStatic({})", + debug!("RootCollector: ItemKind::Static({})", def_id_to_string(self.tcx, def_id)); self.output.push(MonoItem::Static(def_id)); } - hir::ItemConst(..) => { + hir::ItemKind::Const(..) => { // const items only generate mono items if they are // actually used somewhere. Just declaring them is insufficient. @@ -1001,7 +1001,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { self.output.push(MonoItem::CustomSection(def_id)); } } - hir::ItemFn(..) => { + hir::ItemKind::Fn(..) => { let def_id = self.tcx.hir.local_def_id(item.id); self.push_if_root(def_id); } @@ -1102,7 +1102,7 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &'tcx hir::Item, output: &mut Vec<MonoItem<'tcx>>) { match item.node { - hir::ItemImpl(_, _, _, ref generics, .., ref impl_item_refs) => { + hir::ItemKind::Impl(_, _, _, ref generics, .., ref impl_item_refs) => { for param in &generics.params { match param.kind { hir::GenericParamKind::Lifetime { .. } => {} diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 7768e96d036..b4f0a7cd6c4 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -405,7 +405,7 @@ fn is_enclosed(tcx: TyCtxt, if used_unsafe.contains(&parent_id) { Some(("block".to_string(), parent_id)) } else if let Some(hir::map::NodeItem(&hir::Item { - node: hir::ItemFn(_, header, _, _), + node: hir::ItemKind::Fn(_, header, _, _), .. })) = tcx.hir.find(parent_id) { match header.unsafety { diff --git a/src/librustc_plugin/build.rs b/src/librustc_plugin/build.rs index 88af8b49b9e..f2728593db4 100644 --- a/src/librustc_plugin/build.rs +++ b/src/librustc_plugin/build.rs @@ -24,7 +24,7 @@ struct RegistrarFinder { impl<'v> ItemLikeVisitor<'v> for RegistrarFinder { fn visit_item(&mut self, item: &hir::Item) { - if let hir::ItemFn(..) = item.node { + if let hir::ItemKind::Fn(..) = item.node { if attr::contains_name(&item.attrs, "plugin_registrar") { self.registrars.push((item.id, item.span)); diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index cd1bc4b4490..826577ff6ba 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -149,21 +149,21 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { let inherited_item_level = match item.node { // Impls inherit level from their types and traits - hir::ItemImpl(..) => { + hir::ItemKind::Impl(..) => { let def_id = self.tcx.hir.local_def_id(item.id); cmp::min(self.item_ty_level(def_id), self.impl_trait_level(def_id)) } // Foreign mods inherit level from parents - hir::ItemForeignMod(..) => { + hir::ItemKind::ForeignMod(..) => { self.prev_level } // Other `pub` items inherit levels from parents - hir::ItemConst(..) | hir::ItemEnum(..) | hir::ItemExternCrate(..) | - hir::ItemGlobalAsm(..) | hir::ItemFn(..) | hir::ItemMod(..) | - hir::ItemStatic(..) | hir::ItemStruct(..) | - hir::ItemTrait(..) | hir::ItemTraitAlias(..) | - hir::ItemExistential(..) | - hir::ItemTy(..) | hir::ItemUnion(..) | hir::ItemUse(..) => { + hir::ItemKind::Const(..) | hir::ItemKind::Enum(..) | hir::ItemKind::ExternCrate(..) | + hir::ItemKind::GlobalAsm(..) | hir::ItemKind::Fn(..) | hir::ItemKind::Mod(..) | + hir::ItemKind::Static(..) | hir::ItemKind::Struct(..) | + hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::Ty(..) | hir::ItemKind::Union(..) | hir::ItemKind::Use(..) => { if item.vis.node.is_pub() { self.prev_level } else { None } } }; @@ -173,7 +173,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { // Update levels of nested things match item.node { - hir::ItemEnum(ref def, _) => { + hir::ItemKind::Enum(ref def, _) => { for variant in &def.variants { let variant_level = self.update(variant.node.data.id(), item_level); for field in variant.node.data.fields() { @@ -181,24 +181,24 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { } } } - hir::ItemImpl(.., None, _, ref impl_item_refs) => { + hir::ItemKind::Impl(.., None, _, ref impl_item_refs) => { for impl_item_ref in impl_item_refs { if impl_item_ref.vis.node.is_pub() { self.update(impl_item_ref.id.node_id, item_level); } } } - hir::ItemImpl(.., Some(_), _, ref impl_item_refs) => { + hir::ItemKind::Impl(.., Some(_), _, ref impl_item_refs) => { for impl_item_ref in impl_item_refs { self.update(impl_item_ref.id.node_id, item_level); } } - hir::ItemTrait(.., ref trait_item_refs) => { + hir::ItemKind::Trait(.., ref trait_item_refs) => { for trait_item_ref in trait_item_refs { self.update(trait_item_ref.id.node_id, item_level); } } - hir::ItemStruct(ref def, _) | hir::ItemUnion(ref def, _) => { + hir::ItemKind::Struct(ref def, _) | hir::ItemKind::Union(ref def, _) => { if !def.is_struct() { self.update(def.id(), item_level); } @@ -208,43 +208,43 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { } } } - hir::ItemForeignMod(ref foreign_mod) => { + hir::ItemKind::ForeignMod(ref foreign_mod) => { for foreign_item in &foreign_mod.items { if foreign_item.vis.node.is_pub() { self.update(foreign_item.id, item_level); } } } - hir::ItemExistential(..) | - hir::ItemUse(..) | hir::ItemStatic(..) | hir::ItemConst(..) | - hir::ItemGlobalAsm(..) | hir::ItemTy(..) | hir::ItemMod(..) | hir::ItemTraitAlias(..) | - hir::ItemFn(..) | hir::ItemExternCrate(..) => {} + hir::ItemKind::Existential(..) | + hir::ItemKind::Use(..) | hir::ItemKind::Static(..) | hir::ItemKind::Const(..) | + hir::ItemKind::GlobalAsm(..) | hir::ItemKind::Ty(..) | hir::ItemKind::Mod(..) | hir::ItemKind::TraitAlias(..) | + hir::ItemKind::Fn(..) | hir::ItemKind::ExternCrate(..) => {} } // Mark all items in interfaces of reachable items as reachable match item.node { // The interface is empty - hir::ItemExternCrate(..) => {} + hir::ItemKind::ExternCrate(..) => {} // All nested items are checked by visit_item - hir::ItemMod(..) => {} + hir::ItemKind::Mod(..) => {} // Re-exports are handled in visit_mod - hir::ItemUse(..) => {} + hir::ItemKind::Use(..) => {} // The interface is empty - hir::ItemGlobalAsm(..) => {} - hir::ItemExistential(..) => { + hir::ItemKind::GlobalAsm(..) => {} + hir::ItemKind::Existential(..) => { if item_level.is_some() { // Reach the (potentially private) type and the API being exposed self.reach(item.id).ty().predicates(); } } // Visit everything - hir::ItemConst(..) | hir::ItemStatic(..) | - hir::ItemFn(..) | hir::ItemTy(..) => { + hir::ItemKind::Const(..) | hir::ItemKind::Static(..) | + hir::ItemKind::Fn(..) | hir::ItemKind::Ty(..) => { if item_level.is_some() { self.reach(item.id).generics().predicates().ty(); } } - hir::ItemTrait(.., ref trait_item_refs) => { + hir::ItemKind::Trait(.., ref trait_item_refs) => { if item_level.is_some() { self.reach(item.id).generics().predicates(); @@ -261,13 +261,13 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { } } } - hir::ItemTraitAlias(..) => { + hir::ItemKind::TraitAlias(..) => { if item_level.is_some() { self.reach(item.id).generics().predicates(); } } // Visit everything except for private impl items - hir::ItemImpl(.., ref trait_ref, _, ref impl_item_refs) => { + hir::ItemKind::Impl(.., ref trait_ref, _, ref impl_item_refs) => { if item_level.is_some() { self.reach(item.id).generics().predicates().impl_trait_ref(); @@ -281,7 +281,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { } // Visit everything, but enum variants have their own levels - hir::ItemEnum(ref def, _) => { + hir::ItemKind::Enum(ref def, _) => { if item_level.is_some() { self.reach(item.id).generics().predicates(); } @@ -297,7 +297,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { } } // Visit everything, but foreign items have their own levels - hir::ItemForeignMod(ref foreign_mod) => { + hir::ItemKind::ForeignMod(ref foreign_mod) => { for foreign_item in &foreign_mod.items { if self.get(foreign_item.id).is_some() { self.reach(foreign_item.id).generics().predicates().ty(); @@ -305,8 +305,8 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { } } // Visit everything except for private fields - hir::ItemStruct(ref struct_def, _) | - hir::ItemUnion(ref struct_def, _) => { + hir::ItemKind::Struct(ref struct_def, _) | + hir::ItemKind::Union(ref struct_def, _) => { if item_level.is_some() { self.reach(item.id).generics().predicates(); for field in struct_def.fields() { @@ -373,7 +373,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { loop { let module = if module_id == ast::CRATE_NODE_ID { &self.tcx.hir.krate().module - } else if let hir::ItemMod(ref module) = self.tcx.hir.expect_item(module_id).node { + } else if let hir::ItemKind::Mod(ref module) = self.tcx.hir.expect_item(module_id).node { module } else { unreachable!() @@ -1084,13 +1084,13 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { match item.node { // contents of a private mod can be re-exported, so we need // to check internals. - hir::ItemMod(_) => {} + hir::ItemKind::Mod(_) => {} // An `extern {}` doesn't introduce a new privacy // namespace (the contents have their own privacies). - hir::ItemForeignMod(_) => {} + hir::ItemKind::ForeignMod(_) => {} - hir::ItemTrait(.., ref bounds, _) => { + hir::ItemKind::Trait(.., ref bounds, _) => { if !self.trait_is_public(item.id) { return } @@ -1105,7 +1105,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { // (i.e. we could just return here to not check them at // all, or some worse estimation of whether an impl is // publicly visible). - hir::ItemImpl(.., ref g, ref trait_ref, ref self_, ref impl_item_refs) => { + hir::ItemKind::Impl(.., ref g, ref trait_ref, ref self_, ref impl_item_refs) => { // `impl [... for] Private` is never visible. let self_contains_private; // impl [... for] Public<...>, but not `impl [... for] @@ -1245,7 +1245,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { // `type ... = ...;` can contain private types, because // we're introducing a new name. - hir::ItemTy(..) => return, + hir::ItemKind::Ty(..) => return, // not at all public, so we don't care _ if !self.item_is_public(&item.id, &item.vis) => { @@ -1552,14 +1552,14 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> match item.node { // Crates are always public - hir::ItemExternCrate(..) => {} + hir::ItemKind::ExternCrate(..) => {} // All nested items are checked by visit_item - hir::ItemMod(..) => {} + hir::ItemKind::Mod(..) => {} // Checked in resolve - hir::ItemUse(..) => {} + hir::ItemKind::Use(..) => {} // No subitems - hir::ItemGlobalAsm(..) => {} - hir::ItemExistential(..) => { + hir::ItemKind::GlobalAsm(..) => {} + hir::ItemKind::Existential(..) => { // Check the traits being exposed, as they're separate, // e.g. `impl Iterator<Item=T>` has two predicates, // `X: Iterator` and `<X as Iterator>::Item == T`, @@ -1569,15 +1569,15 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> self.check(item.id, item_visibility).predicates(); } // Subitems of these items have inherited publicity - hir::ItemConst(..) | hir::ItemStatic(..) | hir::ItemFn(..) | - hir::ItemTy(..) => { + hir::ItemKind::Const(..) | hir::ItemKind::Static(..) | hir::ItemKind::Fn(..) | + hir::ItemKind::Ty(..) => { self.check(item.id, item_visibility).generics().predicates().ty(); // Recurse for e.g. `impl Trait` (see `visit_ty`). self.inner_visibility = item_visibility; intravisit::walk_item(self, item); } - hir::ItemTrait(.., ref trait_item_refs) => { + hir::ItemKind::Trait(.., ref trait_item_refs) => { self.check(item.id, item_visibility).generics().predicates(); for trait_item_ref in trait_item_refs { @@ -1593,10 +1593,10 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> } } } - hir::ItemTraitAlias(..) => { + hir::ItemKind::TraitAlias(..) => { self.check(item.id, item_visibility).generics().predicates(); } - hir::ItemEnum(ref def, _) => { + hir::ItemKind::Enum(ref def, _) => { self.check(item.id, item_visibility).generics().predicates(); for variant in &def.variants { @@ -1606,15 +1606,15 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> } } // Subitems of foreign modules have their own publicity - hir::ItemForeignMod(ref foreign_mod) => { + hir::ItemKind::ForeignMod(ref foreign_mod) => { for foreign_item in &foreign_mod.items { let vis = ty::Visibility::from_hir(&foreign_item.vis, item.id, tcx); self.check(foreign_item.id, vis).generics().predicates().ty(); } } // Subitems of structs and unions have their own publicity - hir::ItemStruct(ref struct_def, _) | - hir::ItemUnion(ref struct_def, _) => { + hir::ItemKind::Struct(ref struct_def, _) | + hir::ItemKind::Union(ref struct_def, _) => { self.check(item.id, item_visibility).generics().predicates(); for field in struct_def.fields() { @@ -1624,7 +1624,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> } // An inherent impl is public when its type is public // Subitems of inherent impls have their own publicity - hir::ItemImpl(.., None, _, ref impl_item_refs) => { + hir::ItemKind::Impl(.., None, _, ref impl_item_refs) => { let ty_vis = self.check(item.id, ty::Visibility::Invisible).ty().min_visibility; self.check(item.id, ty_vis).generics().predicates(); @@ -1643,7 +1643,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> } // A trait impl is public when both its type and its trait are public // Subitems of trait impls have inherited publicity - hir::ItemImpl(.., Some(_), _, ref impl_item_refs) => { + hir::ItemKind::Impl(.., Some(_), _, ref impl_item_refs) => { let vis = self.check(item.id, ty::Visibility::Invisible) .ty().impl_trait_ref().min_visibility; self.check(item.id, vis).generics().predicates(); diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 7355ae4a7c8..f2620c04754 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -420,7 +420,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { match self.tcx.impl_of_method(self.tcx.hir.local_def_id(id)) { Some(impl_id) => match self.tcx.hir.get_if_local(impl_id) { Some(Node::NodeItem(item)) => match item.node { - hir::ItemImpl(.., ref ty, _) => { + hir::ItemKind::Impl(.., ref ty, _) => { let mut qualname = String::from("<"); qualname.push_str(&self.tcx.hir.node_to_pretty_string(ty.id)); @@ -630,7 +630,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { Node::NodeTraitRef(tr) => tr.path.def, Node::NodeItem(&hir::Item { - node: hir::ItemUse(ref path, _), + node: hir::ItemKind::Use(ref path, _), .. }) | Node::NodeVisibility(&Spanned { diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index f7d4bfbeb05..fca35dec067 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -18,7 +18,7 @@ use syntax_pos::Span; use rustc::hir; use rustc::hir::def::Def; use rustc::hir::map::{NodeItem, NodeExpr}; -use rustc::hir::{Item, ItemConst, print}; +use rustc::hir::{Item, ItemKind, print}; use rustc::ty::{self, Ty, AssociatedItem}; use rustc::ty::adjustment::AllowTwoPhase; use errors::{DiagnosticBuilder, CodeMapper}; @@ -376,7 +376,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { match self.tcx.hir.find(parent_id) { Some(parent) => { // Shouldn't suggest `.into()` on `const`s. - if let NodeItem(Item { node: ItemConst(_, _), .. }) = parent { + if let NodeItem(Item { node: ItemKind::Const(_, _), .. }) = parent { // FIXME(estebank): modify once we decide to suggest `as` casts return false; } diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index bd3243e4f48..c2c56edfc09 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -709,7 +709,7 @@ fn compute_all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec<DefId> impl<'v, 'a, 'tcx> itemlikevisit::ItemLikeVisitor<'v> for Visitor<'a, 'tcx> { fn visit_item(&mut self, i: &'v hir::Item) { match i.node { - hir::ItemTrait(..) => { + hir::ItemKind::Trait(..) => { let def_id = self.map.local_def_id(i.id); self.traits.push(def_id); } @@ -810,7 +810,7 @@ impl<'a, 'tcx, 'gcx> hir::intravisit::Visitor<'tcx> for UsePlacementFinder<'a, ' for item_id in &module.item_ids { let item = self.tcx.hir.expect_item(item_id.id); match item.node { - hir::ItemUse(..) => { + hir::ItemKind::Use(..) => { // don't suggest placing a use before the prelude // import or other generated ones if item.span.ctxt().outer().expn_info().is_none() { @@ -820,7 +820,7 @@ impl<'a, 'tcx, 'gcx> hir::intravisit::Visitor<'tcx> for UsePlacementFinder<'a, ' } }, // don't place use before extern crate - hir::ItemExternCrate(_) => {} + hir::ItemKind::ExternCrate(_) => {} // but place them before the first other item _ => if self.span.map_or(true, |span| item.span < span ) { if item.span.ctxt().outer().expn_info().is_none() { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 4aa11526acd..9f83f8a00b1 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -132,7 +132,7 @@ use syntax_pos::{self, BytePos, Span, MultiSpan}; use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap}; use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir::map::Node; -use rustc::hir::{self, PatKind, Item_}; +use rustc::hir::{self, PatKind, ItemKind}; use rustc::middle::lang_items; mod autoderef; @@ -759,10 +759,10 @@ fn primary_body_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match tcx.hir.get(id) { hir::map::NodeItem(item) => { match item.node { - hir::ItemConst(_, body) | - hir::ItemStatic(_, _, body) => + hir::ItemKind::Const(_, body) | + hir::ItemKind::Static(_, _, body) => Some((body, None)), - hir::ItemFn(ref decl, .., body) => + hir::ItemKind::Fn(ref decl, .., body) => Some((body, Some(decl))), _ => None, @@ -1165,7 +1165,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, } if let Node::NodeItem(item) = fcx.tcx.hir.get(fn_id) { - if let Item_::ItemFn(_, _, ref generics, _) = item.node { + if let ItemKind::Fn(_, _, ref generics, _) = item.node { if !generics.params.is_empty() { fcx.tcx.sess.span_err( span, @@ -1213,7 +1213,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, } if let Node::NodeItem(item) = fcx.tcx.hir.get(fn_id) { - if let Item_::ItemFn(_, _, ref generics, _) = item.node { + if let ItemKind::Fn(_, _, ref generics, _) = item.node { if !generics.params.is_empty() { fcx.tcx.sess.span_err( span, @@ -1269,25 +1269,25 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item let _indenter = indenter(); match it.node { // Consts can play a role in type-checking, so they are included here. - hir::ItemStatic(..) => { + hir::ItemKind::Static(..) => { tcx.typeck_tables_of(tcx.hir.local_def_id(it.id)); } - hir::ItemConst(..) => { + hir::ItemKind::Const(..) => { tcx.typeck_tables_of(tcx.hir.local_def_id(it.id)); if it.attrs.iter().any(|a| a.check_name("wasm_custom_section")) { let def_id = tcx.hir.local_def_id(it.id); check_const_is_u8_array(tcx, def_id, it.span); } } - hir::ItemEnum(ref enum_definition, _) => { + hir::ItemKind::Enum(ref enum_definition, _) => { check_enum(tcx, it.span, &enum_definition.variants, it.id); } - hir::ItemFn(..) => {} // entirely within check_item_body - hir::ItemImpl(.., ref impl_item_refs) => { - debug!("ItemImpl {} with id {}", it.name, it.id); + hir::ItemKind::Fn(..) => {} // entirely within check_item_body + hir::ItemKind::Impl(.., ref impl_item_refs) => { + debug!("ItemKind::Impl {} with id {}", it.name, it.id); let impl_def_id = tcx.hir.local_def_id(it.id); if let Some(impl_trait_ref) = tcx.impl_trait_ref(impl_def_id) { check_impl_items_against_trait(tcx, @@ -1299,23 +1299,23 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item check_on_unimplemented(tcx, trait_def_id, it); } } - hir::ItemTrait(..) => { + hir::ItemKind::Trait(..) => { let def_id = tcx.hir.local_def_id(it.id); check_on_unimplemented(tcx, def_id, it); } - hir::ItemStruct(..) => { + hir::ItemKind::Struct(..) => { check_struct(tcx, it.id, it.span); } - hir::ItemUnion(..) => { + hir::ItemKind::Union(..) => { check_union(tcx, it.id, it.span); } - hir::ItemTy(..) => { + hir::ItemKind::Ty(..) => { let def_id = tcx.hir.local_def_id(it.id); let pty_ty = tcx.type_of(def_id); let generics = tcx.generics_of(def_id); check_bounds_are_used(tcx, &generics, pty_ty); } - hir::ItemForeignMod(ref m) => { + hir::ItemKind::ForeignMod(ref m) => { check_abi(tcx, it.span, m.abi); if m.abi == Abi::RustIntrinsic { @@ -4548,7 +4548,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let parent = self.tcx.hir.get(fn_id); if let Node::NodeItem(&hir::Item { - name, node: hir::ItemFn(ref decl, ..), .. + name, node: hir::ItemKind::Fn(ref decl, ..), .. }) = parent { decl.clone().and_then(|decl| { // This is less than ideal, it will not suggest a return type span on any diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 85fdcd417ff..d876f41ce13 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -97,7 +97,7 @@ pub fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: Def // // won't be allowed unless there's an *explicit* implementation of `Send` // for `T` - hir::ItemImpl(_, polarity, defaultness, _, ref trait_ref, ref self_ty, _) => { + hir::ItemKind::Impl(_, polarity, defaultness, _, ref trait_ref, ref self_ty, _) => { let is_auto = tcx.impl_trait_ref(tcx.hir.local_def_id(item.id)) .map_or(false, |trait_ref| tcx.trait_is_auto(trait_ref.def_id)); if let (hir::Defaultness::Default { .. }, true) = (defaultness, is_auto) { @@ -114,37 +114,37 @@ pub fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: Def } } } - hir::ItemFn(..) => { + hir::ItemKind::Fn(..) => { check_item_fn(tcx, item); } - hir::ItemStatic(..) => { + hir::ItemKind::Static(..) => { check_item_type(tcx, item); } - hir::ItemConst(..) => { + hir::ItemKind::Const(..) => { check_item_type(tcx, item); } - hir::ItemStruct(ref struct_def, ref ast_generics) => { + hir::ItemKind::Struct(ref struct_def, ref ast_generics) => { check_type_defn(tcx, item, false, |fcx| { vec![fcx.non_enum_variant(struct_def)] }); check_variances_for_type_defn(tcx, item, ast_generics); } - hir::ItemUnion(ref struct_def, ref ast_generics) => { + hir::ItemKind::Union(ref struct_def, ref ast_generics) => { check_type_defn(tcx, item, true, |fcx| { vec![fcx.non_enum_variant(struct_def)] }); check_variances_for_type_defn(tcx, item, ast_generics); } - hir::ItemEnum(ref enum_def, ref ast_generics) => { + hir::ItemKind::Enum(ref enum_def, ref ast_generics) => { check_type_defn(tcx, item, true, |fcx| { fcx.enum_variants(enum_def) }); check_variances_for_type_defn(tcx, item, ast_generics); } - hir::ItemTrait(..) => { + hir::ItemKind::Trait(..) => { check_trait(tcx, item); } _ => {} diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs index 3a8ed0ea25f..1a57dfd745e 100644 --- a/src/librustc_typeck/check_unused.rs +++ b/src/librustc_typeck/check_unused.rs @@ -42,7 +42,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CheckVisitor<'a, 'tcx> { if item.vis.node.is_pub() || item.span.is_dummy() { return; } - if let hir::ItemUse(ref path, _) = item.node { + if let hir::ItemKind::Use(ref path, _) = item.node { self.check_import(item.id, path.span); } } @@ -196,7 +196,7 @@ struct ExternCrateToLint { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CollectExternCrateVisitor<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { - if let hir::ItemExternCrate(orig_name) = item.node { + if let hir::ItemKind::ExternCrate(orig_name) = item.node { let extern_crate_def_id = self.tcx.hir.local_def_id(item.id); self.crates_to_lint.push( ExternCrateToLint { diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs index 393904583ca..4d9a4a03a6b 100644 --- a/src/librustc_typeck/coherence/builtin.rs +++ b/src/librustc_typeck/coherence/builtin.rs @@ -24,7 +24,7 @@ use rustc::infer; use rustc::hir::def_id::DefId; use rustc::hir::map as hir_map; -use rustc::hir::{self, ItemImpl}; +use rustc::hir::{self, ItemKind}; pub fn check_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_def_id: DefId) { Checker { tcx, trait_def_id } @@ -64,7 +64,7 @@ fn visit_implementation_of_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match tcx.hir.find(impl_node_id) { Some(hir_map::NodeItem(item)) => { let span = match item.node { - ItemImpl(.., ref ty, _) => ty.span, + ItemKind::Impl(.., ref ty, _) => ty.span, _ => item.span, }; struct_span_err!(tcx.sess, @@ -115,7 +115,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, Ok(()) => {} Err(CopyImplementationError::InfrigingFields(fields)) => { let item = tcx.hir.expect_item(impl_node_id); - let span = if let ItemImpl(.., Some(ref tr), _, _) = item.node { + let span = if let ItemKind::Impl(.., Some(ref tr), _, _) = item.node { tr.path.span } else { span @@ -132,7 +132,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } Err(CopyImplementationError::NotAnAdt) => { let item = tcx.hir.expect_item(impl_node_id); - let span = if let ItemImpl(.., ref ty, _) = item.node { + let span = if let ItemKind::Impl(.., ref ty, _) = item.node { ty.span } else { span @@ -336,7 +336,7 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>, return err_info; } else if diff_fields.len() > 1 { let item = gcx.hir.expect_item(impl_node_id); - let span = if let ItemImpl(.., Some(ref t), _, _) = item.node { + let span = if let ItemKind::Impl(.., Some(ref t), _, _) = item.node { t.path.span } else { gcx.hir.span(impl_node_id) diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs index 532f1da4f30..02a18fa47df 100644 --- a/src/librustc_typeck/coherence/inherent_impls.rs +++ b/src/librustc_typeck/coherence/inherent_impls.rs @@ -94,7 +94,7 @@ struct InherentCollect<'a, 'tcx: 'a> { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { let ty = match item.node { - hir::ItemImpl(.., None, ref ty, _) => ty, + hir::ItemKind::Impl(.., None, ref ty, _) => ty, _ => return }; diff --git a/src/librustc_typeck/coherence/inherent_impls_overlap.rs b/src/librustc_typeck/coherence/inherent_impls_overlap.rs index 6a346b02b79..c0260d6714d 100644 --- a/src/librustc_typeck/coherence/inherent_impls_overlap.rs +++ b/src/librustc_typeck/coherence/inherent_impls_overlap.rs @@ -122,10 +122,10 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentOverlapChecker<'a, 'tcx> { fn visit_item(&mut self, item: &'v hir::Item) { match item.node { - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemTrait(..) | - hir::ItemUnion(..) => { + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Trait(..) | + hir::ItemKind::Union(..) => { let type_def_id = self.tcx.hir.local_def_id(item.id); self.check_for_overlapping_inherent_impls(type_def_id); } diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 6d6594e5543..9be509b3588 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -34,7 +34,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { let def_id = self.tcx.hir.local_def_id(item.id); match item.node { - hir::ItemImpl(.., Some(_), _, _) => { + hir::ItemKind::Impl(.., Some(_), _, _) => { // "Trait" impl debug!("coherence2::orphan check: trait impl {}", self.tcx.hir.node_to_string(item.id)); diff --git a/src/librustc_typeck/coherence/unsafety.rs b/src/librustc_typeck/coherence/unsafety.rs index 5a442881a63..9e19854a571 100644 --- a/src/librustc_typeck/coherence/unsafety.rs +++ b/src/librustc_typeck/coherence/unsafety.rs @@ -84,7 +84,7 @@ impl<'cx, 'tcx, 'v> UnsafetyChecker<'cx, 'tcx> { impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for UnsafetyChecker<'cx, 'tcx> { fn visit_item(&mut self, item: &'v hir::Item) { match item.node { - hir::ItemImpl(unsafety, polarity, _, ref generics, ..) => { + hir::ItemKind::Impl(unsafety, polarity, _, ref generics, ..) => { self.check_unsafety_coherence(item, Some(generics), unsafety, polarity); } _ => {} diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index e9f3cae080c..7fcfea0cead 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -266,13 +266,13 @@ fn type_param_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, NodeItem(item) => { match item.node { - ItemFn(.., ref generics, _) | - ItemImpl(_, _, _, ref generics, ..) | - ItemTy(_, ref generics) | - ItemEnum(_, ref generics) | - ItemStruct(_, ref generics) | - ItemUnion(_, ref generics) => generics, - ItemTrait(_, _, ref generics, ..) => { + ItemKind::Fn(.., ref generics, _) | + ItemKind::Impl(_, _, _, ref generics, ..) | + ItemKind::Ty(_, ref generics) | + ItemKind::Enum(_, ref generics) | + ItemKind::Struct(_, ref generics) | + ItemKind::Union(_, ref generics) => generics, + ItemKind::Trait(_, _, ref generics, ..) => { // Implied `Self: Trait` and supertrait bounds. if param_id == item_node_id { result.predicates.push( @@ -365,11 +365,11 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) { let def_id = tcx.hir.local_def_id(item_id); match it.node { // These don't define types. - hir::ItemExternCrate(_) | - hir::ItemUse(..) | - hir::ItemMod(_) | - hir::ItemGlobalAsm(_) => {} - hir::ItemForeignMod(ref foreign_mod) => { + hir::ItemKind::ExternCrate(_) | + hir::ItemKind::Use(..) | + hir::ItemKind::Mod(_) | + hir::ItemKind::GlobalAsm(_) => {} + hir::ItemKind::ForeignMod(ref foreign_mod) => { for item in &foreign_mod.items { let def_id = tcx.hir.local_def_id(item.id); tcx.generics_of(def_id); @@ -380,30 +380,30 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) { } } } - hir::ItemEnum(ref enum_definition, _) => { + hir::ItemKind::Enum(ref enum_definition, _) => { tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); convert_enum_variant_types(tcx, def_id, &enum_definition.variants); }, - hir::ItemImpl(..) => { + hir::ItemKind::Impl(..) => { tcx.generics_of(def_id); tcx.type_of(def_id); tcx.impl_trait_ref(def_id); tcx.predicates_of(def_id); }, - hir::ItemTrait(..) => { + hir::ItemKind::Trait(..) => { tcx.generics_of(def_id); tcx.trait_def(def_id); tcx.at(it.span).super_predicates_of(def_id); tcx.predicates_of(def_id); }, - hir::ItemTraitAlias(..) => { + hir::ItemKind::TraitAlias(..) => { span_err!(tcx.sess, it.span, E0645, "trait aliases are not yet implemented (see issue #41517)"); }, - hir::ItemStruct(ref struct_def, _) | - hir::ItemUnion(ref struct_def, _) => { + hir::ItemKind::Struct(ref struct_def, _) | + hir::ItemKind::Union(ref struct_def, _) => { tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); @@ -419,12 +419,12 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) { convert_variant_ctor(tcx, struct_def.id()); } }, - hir::ItemExistential(..) => {} - hir::ItemTy(..) | hir::ItemStatic(..) | hir::ItemConst(..) | hir::ItemFn(..) => { + hir::ItemKind::Existential(..) => {} + hir::ItemKind::Ty(..) | hir::ItemKind::Static(..) | hir::ItemKind::Const(..) | hir::ItemKind::Fn(..) => { tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); - if let hir::ItemFn(..) = it.node { + if let hir::ItemKind::Fn(..) = it.node { tcx.fn_sig(def_id); } } @@ -561,7 +561,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let repr = ReprOptions::new(tcx, def_id); let (kind, variants) = match item.node { - ItemEnum(ref def, _) => { + ItemKind::Enum(ref def, _) => { let mut distance_from_explicit = 0; (AdtKind::Enum, def.variants.iter().map(|v| { let did = tcx.hir.local_def_id(v.node.data.id()); @@ -576,7 +576,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, convert_struct_variant(tcx, did, v.node.name, discr, &v.node.data) }).collect()) } - ItemStruct(ref def, _) => { + ItemKind::Struct(ref def, _) => { // Use separate constructor id for unit/tuple structs and reuse did for braced structs. let ctor_id = if !def.is_struct() { Some(tcx.hir.local_def_id(def.id())) @@ -588,7 +588,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty::VariantDiscr::Relative(0), def) ]) } - ItemUnion(ref def, _) => { + ItemKind::Union(ref def, _) => { (AdtKind::Union, vec![ convert_struct_variant(tcx, def_id, item.name, ty::VariantDiscr::Relative(0), def) @@ -614,8 +614,8 @@ fn super_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }; let (generics, bounds) = match item.node { - hir::ItemTrait(.., ref generics, ref supertraits, _) => (generics, supertraits), - hir::ItemTraitAlias(ref generics, ref supertraits) => (generics, supertraits), + hir::ItemKind::Trait(.., ref generics, ref supertraits, _) => (generics, supertraits), + hir::ItemKind::TraitAlias(ref generics, ref supertraits) => (generics, supertraits), _ => span_bug!(item.span, "super_predicates invoked on non-trait"), }; @@ -658,8 +658,8 @@ fn trait_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let item = tcx.hir.expect_item(node_id); let (is_auto, unsafety) = match item.node { - hir::ItemTrait(is_auto, unsafety, ..) => (is_auto == hir::IsAuto::Yes, unsafety), - hir::ItemTraitAlias(..) => (false, hir::Unsafety::Normal), + hir::ItemKind::Trait(is_auto, unsafety, ..) => (is_auto == hir::IsAuto::Yes, unsafety), + hir::ItemKind::TraitAlias(..) => (false, hir::Unsafety::Normal), _ => span_bug!(item.span, "trait_def_of_item invoked on non-trait"), }; @@ -779,7 +779,7 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, _ => None, }, hir_map::NodeItem(item) => match item.node { - hir::ItemFn(ref fn_decl, .., ref generics, _) => + hir::ItemKind::Fn(ref fn_decl, .., ref generics, _) => has_late_bound_regions(tcx, generics, fn_decl), _ => None, }, @@ -810,7 +810,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } NodeItem(item) => { match item.node { - ItemExistential(hir::ExistTy { impl_trait_fn, .. }) => impl_trait_fn, + ItemKind::Existential(hir::ExistTy { impl_trait_fn, .. }) => impl_trait_fn, _ => None, } }, @@ -828,19 +828,19 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, NodeItem(item) => { match item.node { - ItemFn(.., ref generics, _) | - ItemImpl(_, _, _, ref generics, ..) => generics, - - ItemTy(_, ref generics) | - ItemEnum(_, ref generics) | - ItemStruct(_, ref generics) | - ItemExistential(hir::ExistTy { ref generics, .. }) | - ItemUnion(_, ref generics) => { + ItemKind::Fn(.., ref generics, _) | + ItemKind::Impl(_, _, _, ref generics, ..) => generics, + + ItemKind::Ty(_, ref generics) | + ItemKind::Enum(_, ref generics) | + ItemKind::Struct(_, ref generics) | + ItemKind::Existential(hir::ExistTy { ref generics, .. }) | + ItemKind::Union(_, ref generics) => { allow_defaults = true; generics } - ItemTrait(_, _, ref generics, ..) | ItemTraitAlias(ref generics, ..) => { + ItemKind::Trait(_, _, ref generics, ..) | ItemKind::TraitAlias(ref generics, ..) => { // Add in the self type parameter. // // Something of a hack: use the node id for the trait, also as @@ -1043,33 +1043,33 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, NodeItem(item) => { match item.node { - ItemStatic(ref t, ..) | ItemConst(ref t, _) | - ItemTy(ref t, _) | ItemImpl(.., ref t, _) => { + ItemKind::Static(ref t, ..) | ItemKind::Const(ref t, _) | + ItemKind::Ty(ref t, _) | ItemKind::Impl(.., ref t, _) => { icx.to_ty(t) } - ItemFn(..) => { + ItemKind::Fn(..) => { let substs = Substs::identity_for_item(tcx, def_id); tcx.mk_fn_def(def_id, substs) } - ItemEnum(..) | - ItemStruct(..) | - ItemUnion(..) => { + ItemKind::Enum(..) | + ItemKind::Struct(..) | + ItemKind::Union(..) => { let def = tcx.adt_def(def_id); let substs = Substs::identity_for_item(tcx, def_id); tcx.mk_adt(def, substs) } // this is only reachable once we have named existential types - ItemExistential(hir::ExistTy { impl_trait_fn: None, .. }) => unimplemented!(), + ItemKind::Existential(hir::ExistTy { impl_trait_fn: None, .. }) => unimplemented!(), // existential types desugared from impl Trait - ItemExistential(hir::ExistTy { impl_trait_fn: Some(owner), .. }) => { + ItemKind::Existential(hir::ExistTy { impl_trait_fn: Some(owner), .. }) => { tcx.typeck_tables_of(owner).concrete_existential_types[&def_id] }, - ItemTrait(..) | ItemTraitAlias(..) | - ItemMod(..) | - ItemForeignMod(..) | - ItemGlobalAsm(..) | - ItemExternCrate(..) | - ItemUse(..) => { + ItemKind::Trait(..) | ItemKind::TraitAlias(..) | + ItemKind::Mod(..) | + ItemKind::ForeignMod(..) | + ItemKind::GlobalAsm(..) | + ItemKind::ExternCrate(..) | + ItemKind::Use(..) => { span_bug!( item.span, "compute_type_of_item: unexpected item type: {:?}", @@ -1165,7 +1165,7 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, AstConv::ty_of_fn(&icx, sig.header.unsafety, sig.header.abi, &sig.decl) } - NodeItem(hir::Item { node: ItemFn(decl, header, _, _), .. }) => { + NodeItem(hir::Item { node: ItemKind::Fn(decl, header, _, _), .. }) => { AstConv::ty_of_fn(&icx, header.unsafety, header.abi, decl) } @@ -1223,7 +1223,7 @@ fn impl_trait_ref<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); match tcx.hir.expect_item(node_id).node { - hir::ItemImpl(.., ref opt_trait_ref, _, _) => { + hir::ItemKind::Impl(.., ref opt_trait_ref, _, _) => { opt_trait_ref.as_ref().map(|ast_trait_ref| { let selfty = tcx.type_of(def_id); AstConv::instantiate_mono_trait_ref(&icx, ast_trait_ref, selfty) @@ -1238,7 +1238,7 @@ fn impl_polarity<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, -> hir::ImplPolarity { let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); match tcx.hir.expect_item(node_id).node { - hir::ItemImpl(_, polarity, ..) => polarity, + hir::ItemKind::Impl(_, polarity, ..) => polarity, ref item => bug!("impl_polarity: {:?} not an impl", item) } } @@ -1371,23 +1371,23 @@ fn explicit_predicates_of<'a, 'tcx>( NodeItem(item) => { match item.node { - ItemImpl(_, _, defaultness, ref generics, ..) => { + ItemKind::Impl(_, _, defaultness, ref generics, ..) => { if defaultness.is_default() { is_default_impl_trait = tcx.impl_trait_ref(def_id); } generics } - ItemFn(.., ref generics, _) | - ItemTy(_, ref generics) | - ItemEnum(_, ref generics) | - ItemStruct(_, ref generics) | - ItemUnion(_, ref generics) => generics, + ItemKind::Fn(.., ref generics, _) | + ItemKind::Ty(_, ref generics) | + ItemKind::Enum(_, ref generics) | + ItemKind::Struct(_, ref generics) | + ItemKind::Union(_, ref generics) => generics, - ItemTrait(_, _, ref generics, .., ref items) => { + ItemKind::Trait(_, _, ref generics, .., ref items) => { is_trait = Some((ty::TraitRef::identity(tcx, def_id), items)); generics } - ItemExistential(ref exist_ty) => { + ItemKind::Existential(ref exist_ty) => { let substs = Substs::identity_for_item(tcx, def_id); let anon_ty = tcx.mk_anon(def_id, substs); @@ -1578,7 +1578,7 @@ fn explicit_predicates_of<'a, 'tcx>( // before uses of `U`. This avoids false ambiguity errors // in trait checking. See `setup_constraining_predicates` // for details. - if let NodeItem(&Item { node: ItemImpl(..), .. }) = node { + if let NodeItem(&Item { node: ItemKind::Impl(..), .. }) = node { let self_ty = tcx.type_of(def_id); let trait_ref = tcx.impl_trait_ref(def_id); ctp::setup_constraining_predicates(tcx, diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index b57bb1fccfb..b7921301957 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -72,7 +72,7 @@ struct ImplWfCheck<'a, 'tcx: 'a> { impl<'a, 'tcx> ItemLikeVisitor<'tcx> for ImplWfCheck<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { match item.node { - hir::ItemImpl(.., ref impl_item_refs) => { + hir::ItemKind::Impl(.., ref impl_item_refs) => { let impl_def_id = self.tcx.hir.local_def_id(item.id); enforce_impl_params_are_constrained(self.tcx, impl_def_id, diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index b50f55effad..e343fb1a57b 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -189,7 +189,7 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match tcx.hir.find(main_id) { Some(hir_map::NodeItem(it)) => { match it.node { - hir::ItemFn(.., ref generics, _) => { + hir::ItemKind::Fn(.., ref generics, _) => { let mut error = false; if !generics.params.is_empty() { let msg = format!("`main` function is not allowed to have generic \ @@ -261,7 +261,7 @@ fn check_start_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match tcx.hir.find(start_id) { Some(hir_map::NodeItem(it)) => { match it.node { - hir::ItemFn(.., ref generics, _) => { + hir::ItemKind::Fn(.., ref generics, _) => { let mut error = false; if !generics.params.is_empty() { struct_span_err!(tcx.sess, generics.span, E0132, diff --git a/src/librustc_typeck/outlives/implicit_infer.rs b/src/librustc_typeck/outlives/implicit_infer.rs index a015122d62e..e378f1a2dce 100644 --- a/src/librustc_typeck/outlives/implicit_infer.rs +++ b/src/librustc_typeck/outlives/implicit_infer.rs @@ -77,7 +77,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> { let mut item_required_predicates = RequiredPredicates::default(); match item.node { - hir::ItemUnion(..) | hir::ItemEnum(..) | hir::ItemStruct(..) => { + hir::ItemKind::Union(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Struct(..) => { let adt_def = self.tcx.adt_def(item_did); // Iterate over all fields in item_did diff --git a/src/librustc_typeck/outlives/mod.rs b/src/librustc_typeck/outlives/mod.rs index 9c483924992..5801a6ada3f 100644 --- a/src/librustc_typeck/outlives/mod.rs +++ b/src/librustc_typeck/outlives/mod.rs @@ -41,7 +41,7 @@ fn inferred_outlives_of<'a, 'tcx>( match tcx.hir.get(id) { hir_map::NodeItem(item) => match item.node { - hir::ItemStruct(..) | hir::ItemEnum(..) | hir::ItemUnion(..) => { + hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Union(..) => { let crate_map = tcx.inferred_outlives_crate(LOCAL_CRATE); let predicates = crate_map diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index b346dffdb46..9fecf5e73e7 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -80,8 +80,8 @@ pub fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>) impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { match item.node { - hir::ItemStruct(ref struct_def, _) | - hir::ItemUnion(ref struct_def, _) => { + hir::ItemKind::Struct(ref struct_def, _) | + hir::ItemKind::Union(ref struct_def, _) => { self.visit_node_helper(item.id); if let hir::VariantData::Tuple(..) = *struct_def { @@ -89,7 +89,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> { } } - hir::ItemEnum(ref enum_def, _) => { + hir::ItemKind::Enum(ref enum_def, _) => { self.visit_node_helper(item.id); for variant in &enum_def.variants { @@ -99,11 +99,11 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> { } } - hir::ItemFn(..) => { + hir::ItemKind::Fn(..) => { self.visit_node_helper(item.id); } - hir::ItemForeignMod(ref foreign_mod) => { + hir::ItemKind::ForeignMod(ref foreign_mod) => { for foreign_item in &foreign_mod.items { if let hir::ForeignItemKind::Fn(..) = foreign_item.node { self.visit_node_helper(foreign_item.id); diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index 29c7ee757ca..3d70550c1df 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -62,10 +62,10 @@ fn variances_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId) }; match tcx.hir.get(id) { hir::map::NodeItem(item) => match item.node { - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemFn(..) => {} + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Fn(..) => {} _ => unsupported() }, diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index 1de7bf57422..0aec31609b0 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -142,8 +142,8 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> { self.tcx.hir.node_to_string(item.id)); match item.node { - hir::ItemStruct(ref struct_def, _) | - hir::ItemUnion(ref struct_def, _) => { + hir::ItemKind::Struct(ref struct_def, _) | + hir::ItemKind::Union(ref struct_def, _) => { self.add_inferreds_for_item(item.id); if let hir::VariantData::Tuple(..) = *struct_def { @@ -151,7 +151,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> { } } - hir::ItemEnum(ref enum_def, _) => { + hir::ItemKind::Enum(ref enum_def, _) => { self.add_inferreds_for_item(item.id); for variant in &enum_def.variants { @@ -161,11 +161,11 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> { } } - hir::ItemFn(..) => { + hir::ItemKind::Fn(..) => { self.add_inferreds_for_item(item.id); } - hir::ItemForeignMod(ref foreign_mod) => { + hir::ItemKind::ForeignMod(ref foreign_mod) => { for foreign_item in &foreign_mod.items { if let hir::ForeignItemKind::Fn(..) = foreign_item.node { self.add_inferreds_for_item(foreign_item.id); diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index cbb8b3e3962..0cdab134815 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -10,6 +10,7 @@ use rustc::traits::auto_trait as auto; use rustc::ty::TypeFoldable; +use rustc::hir; use std::fmt::Debug; use super::*; @@ -65,9 +66,9 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> { let did = self.cx.tcx.hir.local_def_id(id); let def_ctor = match *item { - hir::ItemStruct(_, _) => Def::Struct, - hir::ItemUnion(_, _) => Def::Union, - hir::ItemEnum(_, _) => Def::Enum, + hir::ItemKind::Struct(_, _) => Def::Struct, + hir::ItemKind::Union(_, _) => Def::Union, + hir::ItemKind::Enum(_, _) => Def::Enum, _ => panic!("Unexpected type {:?} {:?}", item, id), }; @@ -216,7 +217,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> { let ty = hir::Ty { id: ast::DUMMY_NODE_ID, - node: hir::TyKind::TyPath(hir::QPath::Resolved(None, P(new_path))), + node: hir::TyKind::Path(hir::QPath::Resolved(None, P(new_path))), span: DUMMY_SP, hir_id: hir::DUMMY_HIR_ID, }; @@ -279,7 +280,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> { debug!("ty_param_to_ty({:?}) {:?}", param, param.def_id); hir::Ty { id: ast::DUMMY_NODE_ID, - node: hir::TyKind::TyPath(hir::QPath::Resolved( + node: hir::TyKind::Path(hir::QPath::Resolved( None, P(hir::Path { span: DUMMY_SP, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 021dc6d3418..2bf1f6e553f 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -283,10 +283,10 @@ impl Clean<ExternalCrate> for CrateNum { cx.tcx.hir.krate().module.item_ids.iter().filter_map(|&id| { let item = cx.tcx.hir.expect_item(id.id); match item.node { - hir::ItemMod(_) => { + hir::ItemKind::Mod(_) => { as_primitive(Def::Mod(cx.tcx.hir.local_def_id(id.id))) } - hir::ItemUse(ref path, hir::UseKind::Single) + hir::ItemKind::Use(ref path, hir::UseKind::Single) if item.vis.node.is_pub() => { as_primitive(path.def).map(|(_, prim, attrs)| { // Pretend the primitive is local. @@ -325,10 +325,10 @@ impl Clean<ExternalCrate> for CrateNum { cx.tcx.hir.krate().module.item_ids.iter().filter_map(|&id| { let item = cx.tcx.hir.expect_item(id.id); match item.node { - hir::ItemMod(_) => { + hir::ItemKind::Mod(_) => { as_keyword(Def::Mod(cx.tcx.hir.local_def_id(id.id))) } - hir::ItemUse(ref path, hir::UseKind::Single) + hir::ItemKind::Use(ref path, hir::UseKind::Single) if item.vis.node.is_pub() => { as_keyword(path.def).map(|(_, prim, attrs)| { (cx.tcx.hir.local_def_id(id.id), prim, attrs) @@ -2852,9 +2852,9 @@ impl Clean<Type> for hir::Ty { fn clean(&self, cx: &DocContext) -> Type { use rustc::hir::*; match self.node { - TyNever => Never, - TyPtr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)), - TyRptr(ref l, ref m) => { + TyKind::Never => Never, + TyKind::Ptr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)), + TyKind::Rptr(ref l, ref m) => { let lifetime = if l.is_elided() { None } else { @@ -2863,8 +2863,8 @@ impl Clean<Type> for hir::Ty { BorrowedRef {lifetime: lifetime, mutability: m.mutbl.clean(cx), type_: box m.ty.clean(cx)} } - TySlice(ref ty) => Slice(box ty.clean(cx)), - TyArray(ref ty, ref length) => { + TyKind::Slice(ref ty) => Slice(box ty.clean(cx)), + TyKind::Array(ref ty, ref length) => { let def_id = cx.tcx.hir.local_def_id(length.id); let param_env = cx.tcx.param_env(def_id); let substs = Substs::identity_for_item(cx.tcx, def_id); @@ -2878,8 +2878,8 @@ impl Clean<Type> for hir::Ty { let length = print_const(cx, length); Array(box ty.clean(cx), length) }, - TyTup(ref tys) => Tuple(tys.clean(cx)), - TyPath(hir::QPath::Resolved(None, ref path)) => { + TyKind::Tup(ref tys) => Tuple(tys.clean(cx)), + TyKind::Path(hir::QPath::Resolved(None, ref path)) => { if let Some(new_ty) = cx.ty_substs.borrow().get(&path.def).cloned() { return new_ty; } @@ -2900,7 +2900,7 @@ impl Clean<Type> for hir::Ty { } }; - if let Some(&hir::ItemTy(ref ty, ref generics)) = alias { + if let Some(&hir::ItemKind::Ty(ref ty, ref generics)) = alias { let provided_params = &path.segments.last().unwrap(); let mut ty_substs = FxHashMap(); let mut lt_substs = FxHashMap(); @@ -2965,7 +2965,7 @@ impl Clean<Type> for hir::Ty { } resolve_type(cx, path.clean(cx), self.id) } - TyPath(hir::QPath::Resolved(Some(ref qself), ref p)) => { + TyKind::Path(hir::QPath::Resolved(Some(ref qself), ref p)) => { let mut segments: Vec<_> = p.segments.clone().into(); segments.pop(); let trait_path = hir::Path { @@ -2979,7 +2979,7 @@ impl Clean<Type> for hir::Ty { trait_: box resolve_type(cx, trait_path.clean(cx), self.id) } } - TyPath(hir::QPath::TypeRelative(ref qself, ref segment)) => { + TyKind::Path(hir::QPath::TypeRelative(ref qself, ref segment)) => { let mut def = Def::Err; let ty = hir_ty_to_ty(cx.tcx, self); if let ty::TyProjection(proj) = ty.sty { @@ -2996,7 +2996,7 @@ impl Clean<Type> for hir::Ty { trait_: box resolve_type(cx, trait_path.clean(cx), self.id) } } - TyTraitObject(ref bounds, ref lifetime) => { + TyKind::TraitObject(ref bounds, ref lifetime) => { match bounds[0].clean(cx).trait_ { ResolvedPath { path, typarams: None, did, is_generic } => { let mut bounds: Vec<self::GenericBound> = bounds[1..].iter().map(|bound| { @@ -3011,9 +3011,9 @@ impl Clean<Type> for hir::Ty { _ => Infer // shouldn't happen } } - TyBareFn(ref barefn) => BareFunction(box barefn.clean(cx)), - TyInfer | TyErr => Infer, - TyTypeof(..) => panic!("Unimplemented type {:?}", self.node), + TyKind::BareFn(ref barefn) => BareFunction(box barefn.clean(cx)), + TyKind::Infer | TyKind::Err => Infer, + TyKind::Typeof(..) => panic!("Unimplemented type {:?}", self.node), } } } @@ -4370,7 +4370,7 @@ pub fn path_to_def_local(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> { } items = match &item.node { - &hir::ItemMod(ref m) => m.item_ids.clone(), + &hir::ItemKind::Mod(ref m) => m.item_ids.clone(), _ => panic!("Unexpected item {:?} in path {:?} path") }; break; diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 53032b9b98c..bd35cc0acda 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -706,7 +706,7 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirCollector<'a, 'hir> { } fn visit_item(&mut self, item: &'hir hir::Item) { - let name = if let hir::ItemImpl(.., ref ty, _) = item.node { + let name = if let hir::ItemKind::Impl(.., ref ty, _) = item.node { self.map.node_to_pretty_string(ty.id) } else { item.name.to_string() diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index b7a9f95fdc0..875ba111ec0 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -297,7 +297,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { if !self.view_item_stack.insert(def_node_id) { return false } let ret = match tcx.hir.get(def_node_id) { - hir_map::NodeItem(&hir::Item { node: hir::ItemMod(ref m), .. }) if glob => { + hir_map::NodeItem(&hir::Item { node: hir::ItemKind::Mod(ref m), .. }) if glob => { let prev = mem::replace(&mut self.inlining, true); for i in &m.item_ids { let i = self.cx.tcx.hir.expect_item(i.id); @@ -340,7 +340,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { } match item.node { - hir::ItemForeignMod(ref fm) => { + hir::ItemKind::ForeignMod(ref fm) => { // If inlining we only want to include public functions. om.foreigns.push(if self.inlining { hir::ForeignMod { @@ -353,8 +353,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { } // If we're inlining, skip private items. _ if self.inlining && !item.vis.node.is_pub() => {} - hir::ItemGlobalAsm(..) => {} - hir::ItemExternCrate(orig_name) => { + hir::ItemKind::GlobalAsm(..) => {} + hir::ItemKind::ExternCrate(orig_name) => { let def_id = self.cx.tcx.hir.local_def_id(item.id); om.extern_crates.push(ExternCrate { cnum: self.cx.tcx.extern_mod_stmt_cnum(def_id) @@ -366,8 +366,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { whence: item.span, }) } - hir::ItemUse(_, hir::UseKind::ListStem) => {} - hir::ItemUse(ref path, kind) => { + hir::ItemKind::Use(_, hir::UseKind::ListStem) => {} + hir::ItemKind::Use(ref path, kind) => { let is_glob = kind == hir::UseKind::Glob; // struct and variant constructors always show up alongside their definitions, we've @@ -409,7 +409,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { whence: item.span, }); } - hir::ItemMod(ref m) => { + hir::ItemKind::Mod(ref m) => { om.mods.push(self.visit_mod_contents(item.span, item.attrs.clone(), item.vis.clone(), @@ -417,15 +417,15 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { m, Some(name))); }, - hir::ItemEnum(ref ed, ref gen) => + hir::ItemKind::Enum(ref ed, ref gen) => om.enums.push(self.visit_enum_def(item, name, ed, gen)), - hir::ItemStruct(ref sd, ref gen) => + hir::ItemKind::Struct(ref sd, ref gen) => om.structs.push(self.visit_variant_data(item, name, sd, gen)), - hir::ItemUnion(ref sd, ref gen) => + hir::ItemKind::Union(ref sd, ref gen) => om.unions.push(self.visit_union_data(item, name, sd, gen)), - hir::ItemFn(ref fd, header, ref gen, body) => + hir::ItemKind::Fn(ref fd, header, ref gen, body) => om.fns.push(self.visit_fn(item, name, &**fd, header, gen, body)), - hir::ItemTy(ref ty, ref gen) => { + hir::ItemKind::Ty(ref ty, ref gen) => { let t = Typedef { ty: ty.clone(), gen: gen.clone(), @@ -439,7 +439,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { }; om.typedefs.push(t); }, - hir::ItemStatic(ref ty, ref mut_, ref exp) => { + hir::ItemKind::Static(ref ty, ref mut_, ref exp) => { let s = Static { type_: ty.clone(), mutability: mut_.clone(), @@ -454,7 +454,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { }; om.statics.push(s); }, - hir::ItemConst(ref ty, ref exp) => { + hir::ItemKind::Const(ref ty, ref exp) => { let s = Constant { type_: ty.clone(), expr: exp.clone(), @@ -468,7 +468,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { }; om.constants.push(s); }, - hir::ItemTrait(is_auto, unsafety, ref gen, ref b, ref item_ids) => { + hir::ItemKind::Trait(is_auto, unsafety, ref gen, ref b, ref item_ids) => { let items = item_ids.iter() .map(|ti| self.cx.tcx.hir.trait_item(ti.id).clone()) .collect(); @@ -488,11 +488,11 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { }; om.traits.push(t); }, - hir::ItemTraitAlias(..) => { + hir::ItemKind::TraitAlias(..) => { unimplemented!("trait objects are not yet implemented") }, - hir::ItemImpl(unsafety, + hir::ItemKind::Impl(unsafety, polarity, defaultness, ref gen, @@ -523,7 +523,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { om.impls.push(i); } }, - hir::ItemExistential(_) => { + hir::ItemKind::Existential(_) => { // FIXME(oli-obk): actually generate docs for real existential items } } |
