This commit is contained in:
csmoe 2018-07-11 23:36:06 +08:00 committed by Oliver Schneider
parent 7e5d224472
commit 5b0cf56f32
61 changed files with 693 additions and 693 deletions

View File

@ -38,13 +38,13 @@ enum Target {
impl Target { impl Target {
fn from_item(item: &hir::Item) -> Target { fn from_item(item: &hir::Item) -> Target {
match item.node { match item.node {
hir::ItemFn(..) => Target::Fn, hir::ItemKind::Fn(..) => Target::Fn,
hir::ItemStruct(..) => Target::Struct, hir::ItemKind::Struct(..) => Target::Struct,
hir::ItemUnion(..) => Target::Union, hir::ItemKind::Union(..) => Target::Union,
hir::ItemEnum(..) => Target::Enum, hir::ItemKind::Enum(..) => Target::Enum,
hir::ItemConst(..) => Target::Const, hir::ItemKind::Const(..) => Target::Const,
hir::ItemForeignMod(..) => Target::ForeignMod, hir::ItemKind::ForeignMod(..) => Target::ForeignMod,
hir::ItemStatic(..) => Target::Static, hir::ItemKind::Static(..) => Target::Static,
_ => Target::Other, _ => 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 { 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 { for variant in &def.variants {
match variant.node.data { match variant.node.data {
hir::VariantData::Unit(_) => { /* continue */ } hir::VariantData::Unit(_) => { /* continue */ }

View File

@ -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_vis(&item.vis);
visitor.visit_name(item.span, item.name); visitor.visit_name(item.span, item.name);
match item.node { match item.node {
ItemExternCrate(orig_name) => { ItemKind::ExternCrate(orig_name) => {
visitor.visit_id(item.id); visitor.visit_id(item.id);
if let Some(orig_name) = orig_name { if let Some(orig_name) = orig_name {
visitor.visit_name(item.span, orig_name); visitor.visit_name(item.span, orig_name);
} }
} }
ItemUse(ref path, _) => { ItemKind::Use(ref path, _) => {
visitor.visit_id(item.id); visitor.visit_id(item.id);
visitor.visit_path(path, item.id); visitor.visit_path(path, item.id);
} }
ItemStatic(ref typ, _, body) | ItemKind::Static(ref typ, _, body) |
ItemConst(ref typ, body) => { ItemKind::Const(ref typ, body) => {
visitor.visit_id(item.id); visitor.visit_id(item.id);
visitor.visit_ty(typ); visitor.visit_ty(typ);
visitor.visit_nested_body(body); 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, visitor.visit_fn(FnKind::ItemFn(item.name,
generics, generics,
header, header,
@ -490,23 +490,23 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
item.span, item.span,
item.id) item.id)
} }
ItemMod(ref module) => { ItemKind::Mod(ref module) => {
// visit_mod() takes care of visiting the Item's NodeId // visit_mod() takes care of visiting the Item's NodeId
visitor.visit_mod(module, item.span, item.id) visitor.visit_mod(module, item.span, item.id)
} }
ItemForeignMod(ref foreign_module) => { ItemKind::ForeignMod(ref foreign_module) => {
visitor.visit_id(item.id); visitor.visit_id(item.id);
walk_list!(visitor, visit_foreign_item, &foreign_module.items); walk_list!(visitor, visit_foreign_item, &foreign_module.items);
} }
ItemGlobalAsm(_) => { ItemKind::GlobalAsm(_) => {
visitor.visit_id(item.id); 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_id(item.id);
visitor.visit_ty(typ); visitor.visit_ty(typ);
visitor.visit_generics(type_parameters) 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); visitor.visit_id(item.id);
walk_generics(visitor, generics); walk_generics(visitor, generics);
walk_list!(visitor, visit_param_bound, bounds); 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)) 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); visitor.visit_generics(type_parameters);
// visit_enum_def() takes care of visiting the Item's NodeId // visit_enum_def() takes care of visiting the Item's NodeId
visitor.visit_enum_def(enum_definition, type_parameters, item.id, item.span) 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_id(item.id);
visitor.visit_generics(type_parameters); visitor.visit_generics(type_parameters);
walk_list!(visitor, visit_trait_ref, opt_trait_reference); walk_list!(visitor, visit_trait_ref, opt_trait_reference);
visitor.visit_ty(typ); visitor.visit_ty(typ);
walk_list!(visitor, visit_impl_item_ref, impl_item_refs); walk_list!(visitor, visit_impl_item_ref, impl_item_refs);
} }
ItemStruct(ref struct_definition, ref generics) | ItemKind::Struct(ref struct_definition, ref generics) |
ItemUnion(ref struct_definition, ref generics) => { ItemKind::Union(ref struct_definition, ref generics) => {
visitor.visit_generics(generics); visitor.visit_generics(generics);
visitor.visit_id(item.id); visitor.visit_id(item.id);
visitor.visit_variant_data(struct_definition, item.name, generics, item.id, item.span); 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_id(item.id);
visitor.visit_generics(generics); visitor.visit_generics(generics);
walk_list!(visitor, visit_param_bound, bounds); walk_list!(visitor, visit_param_bound, bounds);
walk_list!(visitor, visit_trait_item_ref, trait_item_refs); 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_id(item.id);
visitor.visit_generics(generics); visitor.visit_generics(generics);
walk_list!(visitor, visit_param_bound, bounds); walk_list!(visitor, visit_param_bound, bounds);

View File

@ -384,8 +384,8 @@ impl<'a> LoweringContext<'a> {
if item_lowered { if item_lowered {
let item_generics = match self.lctx.items.get(&item.id).unwrap().node { let item_generics = match self.lctx.items.get(&item.id).unwrap().node {
hir::Item_::ItemImpl(_, _, _, ref generics, ..) hir::ItemKind::Impl(_, _, _, ref generics, ..)
| hir::Item_::ItemTrait(_, _, ref generics, ..) => { | hir::ItemKind::Trait(_, _, ref generics, ..) => {
generics.params.clone() generics.params.clone()
} }
_ => HirVec::new(), _ => HirVec::new(),
@ -1274,7 +1274,7 @@ impl<'a> LoweringContext<'a> {
); );
self.with_hir_id_owner(exist_ty_node_id, |lctx| { 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 { generics: hir::Generics {
params: lifetime_defs, params: lifetime_defs,
where_clause: hir::WhereClause { where_clause: hir::WhereClause {
@ -2575,9 +2575,9 @@ impl<'a> LoweringContext<'a> {
attrs: &hir::HirVec<Attribute>, attrs: &hir::HirVec<Attribute>,
vis: &mut hir::Visibility, vis: &mut hir::Visibility,
i: &ItemKind, i: &ItemKind,
) -> hir::Item_ { ) -> hir::ItemKind {
match *i { match *i {
ItemKind::ExternCrate(orig_name) => hir::ItemExternCrate(orig_name), ItemKind::ExternCrate(orig_name) => hir::ItemKind::ExternCrate(orig_name),
ItemKind::Use(ref use_tree) => { ItemKind::Use(ref use_tree) => {
// Start with an empty prefix // Start with an empty prefix
let prefix = Path { let prefix = Path {
@ -2589,7 +2589,7 @@ impl<'a> LoweringContext<'a> {
} }
ItemKind::Static(ref t, m, ref e) => { ItemKind::Static(ref t, m, ref e) => {
let value = self.lower_body(None, |this| this.lower_expr(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_ty(t, ImplTraitContext::Disallowed),
self.lower_mutability(m), self.lower_mutability(m),
value, value,
@ -2597,7 +2597,7 @@ impl<'a> LoweringContext<'a> {
} }
ItemKind::Const(ref t, ref e) => { ItemKind::Const(ref t, ref e) => {
let value = self.lower_body(None, |this| this.lower_expr(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) => { ItemKind::Fn(ref decl, header, ref generics, ref body) => {
let fn_def_id = self.resolver.definitions().local_def_id(id); 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()), decl, Some((fn_def_id, idty)), true, header.asyncness.opt_return_id()),
); );
hir::ItemFn( hir::ItemKind::Fn(
fn_decl, fn_decl,
this.lower_fn_header(header), this.lower_fn_header(header),
generics, generics,
@ -2625,14 +2625,14 @@ impl<'a> LoweringContext<'a> {
) )
}) })
} }
ItemKind::Mod(ref m) => hir::ItemMod(self.lower_mod(m)), ItemKind::Mod(ref m) => hir::ItemKind::Mod(self.lower_mod(m)),
ItemKind::ForeignMod(ref nm) => hir::ItemForeignMod(self.lower_foreign_mod(nm)), ItemKind::ForeignMod(ref nm) => hir::ItemKind::ForeignMod(self.lower_foreign_mod(nm)),
ItemKind::GlobalAsm(ref ga) => hir::ItemGlobalAsm(self.lower_global_asm(ga)), ItemKind::GlobalAsm(ref ga) => hir::ItemKind::GlobalAsm(self.lower_global_asm(ga)),
ItemKind::Ty(ref t, ref generics) => hir::ItemTy( ItemKind::Ty(ref t, ref generics) => hir::ItemKind::Ty(
self.lower_ty(t, ImplTraitContext::Disallowed), self.lower_ty(t, ImplTraitContext::Disallowed),
self.lower_generics(generics, 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 { hir::EnumDef {
variants: enum_definition variants: enum_definition
.variants .variants
@ -2644,14 +2644,14 @@ impl<'a> LoweringContext<'a> {
), ),
ItemKind::Struct(ref struct_def, ref generics) => { ItemKind::Struct(ref struct_def, ref generics) => {
let struct_def = self.lower_variant_data(struct_def); let struct_def = self.lower_variant_data(struct_def);
hir::ItemStruct( hir::ItemKind::Struct(
struct_def, struct_def,
self.lower_generics(generics, ImplTraitContext::Disallowed), self.lower_generics(generics, ImplTraitContext::Disallowed),
) )
} }
ItemKind::Union(ref vdata, ref generics) => { ItemKind::Union(ref vdata, ref generics) => {
let vdata = self.lower_variant_data(vdata); let vdata = self.lower_variant_data(vdata);
hir::ItemUnion( hir::ItemKind::Union(
vdata, vdata,
self.lower_generics(generics, ImplTraitContext::Disallowed), 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_unsafety(unsafety),
self.lower_impl_polarity(polarity), self.lower_impl_polarity(polarity),
self.lower_defaultness(defaultness, true /* [1] */), self.lower_defaultness(defaultness, true /* [1] */),
@ -2727,7 +2727,7 @@ impl<'a> LoweringContext<'a> {
.iter() .iter()
.map(|item| self.lower_trait_item_ref(item)) .map(|item| self.lower_trait_item_ref(item))
.collect(); .collect();
hir::ItemTrait( hir::ItemKind::Trait(
self.lower_is_auto(is_auto), self.lower_is_auto(is_auto),
self.lower_unsafety(unsafety), self.lower_unsafety(unsafety),
self.lower_generics(generics, ImplTraitContext::Disallowed), self.lower_generics(generics, ImplTraitContext::Disallowed),
@ -2735,7 +2735,7 @@ impl<'a> LoweringContext<'a> {
items, 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_generics(generics, ImplTraitContext::Disallowed),
self.lower_param_bounds(bounds, ImplTraitContext::Disallowed), self.lower_param_bounds(bounds, ImplTraitContext::Disallowed),
), ),
@ -2754,7 +2754,7 @@ impl<'a> LoweringContext<'a> {
vis: &mut hir::Visibility, vis: &mut hir::Visibility,
name: &mut Name, name: &mut Name,
attrs: &hir::HirVec<Attribute>, attrs: &hir::HirVec<Attribute>,
) -> hir::Item_ { ) -> hir::ItemKind {
let path = &tree.prefix; let path = &tree.prefix;
match tree.kind { match tree.kind {
@ -2804,7 +2804,7 @@ impl<'a> LoweringContext<'a> {
self.with_hir_id_owner(new_node_id, |this| { self.with_hir_id_owner(new_node_id, |this| {
let new_id = this.lower_node_id(new_node_id); let new_id = this.lower_node_id(new_node_id);
let path = this.lower_path_extra(def, &path, None, ParamMode::Explicit); 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 { let vis_kind = match vis.node {
hir::VisibilityKind::Public => hir::VisibilityKind::Public, hir::VisibilityKind::Public => hir::VisibilityKind::Public,
hir::VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar), 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)); 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 => { UseTreeKind::Glob => {
let path = P(self.lower_path( let path = P(self.lower_path(
@ -2851,7 +2851,7 @@ impl<'a> LoweringContext<'a> {
}, },
ParamMode::Explicit, ParamMode::Explicit,
)); ));
hir::ItemUse(path, hir::UseKind::Glob) hir::ItemKind::Use(path, hir::UseKind::Glob)
} }
UseTreeKind::Nested(ref trees) => { UseTreeKind::Nested(ref trees) => {
let prefix = Path { let prefix = Path {
@ -2912,7 +2912,7 @@ impl<'a> LoweringContext<'a> {
// a re-export by accident when `pub`, e.g. in documentation. // a re-export by accident when `pub`, e.g. in documentation.
let path = P(self.lower_path(id, &prefix, ParamMode::Explicit)); let path = P(self.lower_path(id, &prefix, ParamMode::Explicit));
*vis = respan(prefix.span.shrink_to_lo(), hir::VisibilityKind::Inherited); *vis = respan(prefix.span.shrink_to_lo(), hir::VisibilityKind::Inherited);
hir::ItemUse(path, hir::UseKind::ListStem) hir::ItemKind::Use(path, hir::UseKind::ListStem)
} }
} }
} }

View File

@ -47,7 +47,7 @@ pub trait MaybeFnLike { fn is_fn_like(&self) -> bool; }
impl MaybeFnLike for ast::Item { impl MaybeFnLike for ast::Item {
fn is_fn_like(&self) -> bool { 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 { match self.node {
map::NodeItem(i) => match i.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 { item_fn(ItemFnParts {
id: i.id, id: i.id,
name: i.name, name: i.name,

View File

@ -329,7 +329,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
this.insert(i.id, NodeItem(i)); this.insert(i.id, NodeItem(i));
this.with_parent(i.id, |this| { this.with_parent(i.id, |this| {
match i.node { match i.node {
ItemStruct(ref struct_def, _) => { ItemKind::Struct(ref struct_def, _) => {
// If this is a tuple-like struct, register the constructor. // If this is a tuple-like struct, register the constructor.
if !struct_def.is_struct() { if !struct_def.is_struct() {
this.insert(struct_def.id(), NodeStructCtor(struct_def)); this.insert(struct_def.id(), NodeStructCtor(struct_def));

View File

@ -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) { fn visit_impl_item_ref(&mut self, _: &'hir hir::ImplItemRef) {
// Explicitly do nothing here. ImplItemRefs contain hir::Visibility // 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 // we are currently in. So for those it's correct that they have a
// different owner. // different owner.
} }

View File

@ -175,7 +175,7 @@ impl<'hir> MapEntry<'hir> {
match self { match self {
EntryItem(_, _, ref item) => { EntryItem(_, _, ref item) => {
match item.node { match item.node {
ItemFn(ref fn_decl, _, _, _) => Some(&fn_decl), ItemKind::Fn(ref fn_decl, _, _, _) => Some(&fn_decl),
_ => None, _ => None,
} }
} }
@ -209,9 +209,9 @@ impl<'hir> MapEntry<'hir> {
match self { match self {
EntryItem(_, _, item) => { EntryItem(_, _, item) => {
match item.node { match item.node {
ItemConst(_, body) | ItemKind::Const(_, body) |
ItemStatic(.., body) | ItemKind::Static(.., body) |
ItemFn(_, _, _, body) => Some(body), ItemKind::Fn(_, _, _, body) => Some(body),
_ => None, _ => None,
} }
} }
@ -427,25 +427,25 @@ impl<'hir> Map<'hir> {
}; };
match item.node { match item.node {
ItemStatic(_, m, _) => Some(Def::Static(def_id(), ItemKind::Static(_, m, _) => Some(Def::Static(def_id(),
m == MutMutable)), m == MutMutable)),
ItemConst(..) => Some(Def::Const(def_id())), ItemKind::Const(..) => Some(Def::Const(def_id())),
ItemFn(..) => Some(Def::Fn(def_id())), ItemKind::Fn(..) => Some(Def::Fn(def_id())),
ItemMod(..) => Some(Def::Mod(def_id())), ItemKind::Mod(..) => Some(Def::Mod(def_id())),
ItemGlobalAsm(..) => Some(Def::GlobalAsm(def_id())), ItemKind::GlobalAsm(..) => Some(Def::GlobalAsm(def_id())),
ItemExistential(..) => Some(Def::Existential(def_id())), ItemKind::Existential(..) => Some(Def::Existential(def_id())),
ItemTy(..) => Some(Def::TyAlias(def_id())), ItemKind::Ty(..) => Some(Def::TyAlias(def_id())),
ItemEnum(..) => Some(Def::Enum(def_id())), ItemKind::Enum(..) => Some(Def::Enum(def_id())),
ItemStruct(..) => Some(Def::Struct(def_id())), ItemKind::Struct(..) => Some(Def::Struct(def_id())),
ItemUnion(..) => Some(Def::Union(def_id())), ItemKind::Union(..) => Some(Def::Union(def_id())),
ItemTrait(..) => Some(Def::Trait(def_id())), ItemKind::Trait(..) => Some(Def::Trait(def_id())),
ItemTraitAlias(..) => { ItemKind::TraitAlias(..) => {
bug!("trait aliases are not yet implemented (see issue #41517)") bug!("trait aliases are not yet implemented (see issue #41517)")
}, },
ItemExternCrate(_) | ItemKind::ExternCrate(_) |
ItemUse(..) | ItemKind::Use(..) |
ItemForeignMod(..) | ItemKind::ForeignMod(..) |
ItemImpl(..) => None, ItemKind::Impl(..) => None,
} }
} }
NodeForeignItem(item) => { NodeForeignItem(item) => {
@ -587,13 +587,13 @@ impl<'hir> Map<'hir> {
pub fn body_owner_kind(&self, id: NodeId) -> BodyOwnerKind { pub fn body_owner_kind(&self, id: NodeId) -> BodyOwnerKind {
match self.get(id) { match self.get(id) {
NodeItem(&Item { node: ItemConst(..), .. }) | NodeItem(&Item { node: ItemKind::Const(..), .. }) |
NodeTraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) | NodeTraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) |
NodeImplItem(&ImplItem { node: ImplItemKind::Const(..), .. }) | NodeImplItem(&ImplItem { node: ImplItemKind::Const(..), .. }) |
NodeAnonConst(_) => { NodeAnonConst(_) => {
BodyOwnerKind::Const BodyOwnerKind::Const
} }
NodeItem(&Item { node: ItemStatic(_, m, _), .. }) => { NodeItem(&Item { node: ItemKind::Static(_, m, _), .. }) => {
BodyOwnerKind::Static(m) BodyOwnerKind::Static(m)
} }
// Default to function if it's not a constant or static. // 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 { pub fn ty_param_owner(&self, id: NodeId) -> NodeId {
match self.get(id) { match self.get(id) {
NodeItem(&Item { node: ItemTrait(..), .. }) => id, NodeItem(&Item { node: ItemKind::Trait(..), .. }) => id,
NodeGenericParam(_) => self.get_parent_node(id), NodeGenericParam(_) => self.get_parent_node(id),
_ => { _ => {
bug!("ty_param_owner: {} not a type parameter", 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 { pub fn ty_param_name(&self, id: NodeId) -> Name {
match self.get(id) { match self.get(id) {
NodeItem(&Item { node: ItemTrait(..), .. }) => { NodeItem(&Item { node: ItemKind::Trait(..), .. }) => {
keywords::SelfType.name() keywords::SelfType.name()
} }
NodeGenericParam(param) => param.name.ident().name, NodeGenericParam(param) => param.name.ident().name,
@ -672,14 +672,14 @@ impl<'hir> Map<'hir> {
NodeTraitItem(ref trait_item) => Some(&trait_item.generics), NodeTraitItem(ref trait_item) => Some(&trait_item.generics),
NodeItem(ref item) => { NodeItem(ref item) => {
match item.node { match item.node {
ItemFn(_, _, ref generics, _) | ItemKind::Fn(_, _, ref generics, _) |
ItemTy(_, ref generics) | ItemKind::Ty(_, ref generics) |
ItemEnum(_, ref generics) | ItemKind::Enum(_, ref generics) |
ItemStruct(_, ref generics) | ItemKind::Struct(_, ref generics) |
ItemUnion(_, ref generics) | ItemKind::Union(_, ref generics) |
ItemTrait(_, _, ref generics, ..) | ItemKind::Trait(_, _, ref generics, ..) |
ItemTraitAlias(ref generics, _) | ItemKind::TraitAlias(ref generics, _) |
ItemImpl(_, _, _, ref generics, ..) => Some(generics), ItemKind::Impl(_, _, _, ref generics, ..) => Some(generics),
_ => None, _ => None,
} }
} }
@ -857,7 +857,7 @@ impl<'hir> Map<'hir> {
/// module parent is in this map. /// module parent is in this map.
pub fn get_module_parent(&self, id: NodeId) -> DefId { pub fn get_module_parent(&self, id: NodeId) -> DefId {
let id = match self.walk_parent_nodes(id, |node| match *node { 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,
}, |_| false) { }, |_| false) {
Ok(id) => id, Ok(id) => id,
@ -893,7 +893,7 @@ impl<'hir> Map<'hir> {
let abi = match self.find_entry(parent) { let abi = match self.find_entry(parent) {
Some(EntryItem(_, _, i)) => { Some(EntryItem(_, _, i)) => {
match i.node { match i.node {
ItemForeignMod(ref nm) => Some(nm.abi), ItemKind::ForeignMod(ref nm) => Some(nm.abi),
_ => None _ => None
} }
} }
@ -934,8 +934,8 @@ impl<'hir> Map<'hir> {
match self.find(id) { match self.find(id) {
Some(NodeItem(i)) => { Some(NodeItem(i)) => {
match i.node { match i.node {
ItemStruct(ref struct_def, _) | ItemKind::Struct(ref struct_def, _) |
ItemUnion(ref struct_def, _) => struct_def, ItemKind::Union(ref struct_def, _) => struct_def,
_ => { _ => {
bug!("struct ID bound to non-struct {}", bug!("struct ID bound to non-struct {}",
self.node_to_string(id)); self.node_to_string(id));
@ -1129,7 +1129,7 @@ impl<'a, 'hir> NodesMatchingSuffix<'a, 'hir> {
fn item_is_mod(item: &Item) -> bool { fn item_is_mod(item: &Item) -> bool {
match item.node { match item.node {
ItemMod(_) => true, ItemKind::Mod(_) => true,
_ => false, _ => false,
} }
} }
@ -1314,22 +1314,22 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
match map.find(id) { match map.find(id) {
Some(NodeItem(item)) => { Some(NodeItem(item)) => {
let item_str = match item.node { let item_str = match item.node {
ItemExternCrate(..) => "extern crate", ItemKind::ExternCrate(..) => "extern crate",
ItemUse(..) => "use", ItemKind::Use(..) => "use",
ItemStatic(..) => "static", ItemKind::Static(..) => "static",
ItemConst(..) => "const", ItemKind::Const(..) => "const",
ItemFn(..) => "fn", ItemKind::Fn(..) => "fn",
ItemMod(..) => "mod", ItemKind::Mod(..) => "mod",
ItemForeignMod(..) => "foreign mod", ItemKind::ForeignMod(..) => "foreign mod",
ItemGlobalAsm(..) => "global asm", ItemKind::GlobalAsm(..) => "global asm",
ItemTy(..) => "ty", ItemKind::Ty(..) => "ty",
ItemExistential(..) => "existential", ItemKind::Existential(..) => "existential",
ItemEnum(..) => "enum", ItemKind::Enum(..) => "enum",
ItemStruct(..) => "struct", ItemKind::Struct(..) => "struct",
ItemUnion(..) => "union", ItemKind::Union(..) => "union",
ItemTrait(..) => "trait", ItemKind::Trait(..) => "trait",
ItemTraitAlias(..) => "trait alias", ItemKind::TraitAlias(..) => "trait alias",
ItemImpl(..) => "impl", ItemKind::Impl(..) => "impl",
}; };
format!("{} {}{}", item_str, path_str(), id_str) format!("{} {}{}", item_str, path_str(), id_str)
} }

View File

@ -13,7 +13,6 @@
pub use self::BlockCheckMode::*; pub use self::BlockCheckMode::*;
pub use self::CaptureClause::*; pub use self::CaptureClause::*;
pub use self::FunctionRetTy::*; pub use self::FunctionRetTy::*;
pub use self::Item_::*;
pub use self::Mutability::*; pub use self::Mutability::*;
pub use self::PrimTy::*; pub use self::PrimTy::*;
pub use self::UnOp::*; pub use self::UnOp::*;
@ -2040,7 +2039,7 @@ pub struct Item {
pub id: NodeId, pub id: NodeId,
pub hir_id: HirId, pub hir_id: HirId,
pub attrs: HirVec<Attribute>, pub attrs: HirVec<Attribute>,
pub node: Item_, pub node: ItemKind,
pub vis: Visibility, pub vis: Visibility,
pub span: Span, pub span: Span,
} }
@ -2054,96 +2053,96 @@ pub struct FnHeader {
} }
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] #[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. /// 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` /// 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;` /// `use foo::bar::*;` or `use foo::bar::baz as quux;`
/// ///
/// or just /// or just
/// ///
/// `use foo::bar::baz;` (with `as baz` implicitly on the right) /// `use foo::bar::baz;` (with `as baz` implicitly on the right)
ItemUse(P<Path>, UseKind), Use(P<Path>, UseKind),
/// A `static` item /// A `static` item
ItemStatic(P<Ty>, Mutability, BodyId), Static(P<Ty>, Mutability, BodyId),
/// A `const` item /// A `const` item
ItemConst(P<Ty>, BodyId), Const(P<Ty>, BodyId),
/// A function declaration /// A function declaration
ItemFn(P<FnDecl>, FnHeader, Generics, BodyId), Fn(P<FnDecl>, FnHeader, Generics, BodyId),
/// A module /// A module
ItemMod(Mod), Mod(Mod),
/// An external module /// An external module
ItemForeignMod(ForeignMod), ForeignMod(ForeignMod),
/// Module-level inline assembly (from global_asm!) /// Module-level inline assembly (from global_asm!)
ItemGlobalAsm(P<GlobalAsm>), GlobalAsm(P<GlobalAsm>),
/// A type alias, e.g. `type Foo = Bar<u8>` /// 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>` /// 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>}` /// 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}` /// 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}` /// A union definition, e.g. `union Foo<A, B> {x: A, y: B}`
ItemUnion(VariantData, Generics), Union(VariantData, Generics),
/// Represents a Trait Declaration /// Represents a Trait Declaration
ItemTrait(IsAuto, Unsafety, Generics, GenericBounds, HirVec<TraitItemRef>), Trait(IsAuto, Unsafety, Generics, GenericBounds, HirVec<TraitItemRef>),
/// Represents a Trait Alias Declaration /// Represents a Trait Alias Declaration
ItemTraitAlias(Generics, GenericBounds), TraitAlias(Generics, GenericBounds),
/// An implementation, eg `impl<A> Trait for Foo { .. }` /// An implementation, eg `impl<A> Trait for Foo { .. }`
ItemImpl(Unsafety, Impl(Unsafety,
ImplPolarity, ImplPolarity,
Defaultness, Defaultness,
Generics, Generics,
Option<TraitRef>, // (optional) trait this impl implements Option<TraitRef>, // (optional) trait this impl implements
P<Ty>, // self P<Ty>, // self
HirVec<ImplItemRef>), HirVec<ImplItemRef>),
} }
impl Item_ { impl ItemKind {
pub fn descriptive_variant(&self) -> &str { pub fn descriptive_variant(&self) -> &str {
match *self { match *self {
ItemExternCrate(..) => "extern crate", ItemKind::ExternCrate(..) => "extern crate",
ItemUse(..) => "use", ItemKind::Use(..) => "use",
ItemStatic(..) => "static item", ItemKind::Static(..) => "static item",
ItemConst(..) => "constant item", ItemKind::Const(..) => "constant item",
ItemFn(..) => "function", ItemKind::Fn(..) => "function",
ItemMod(..) => "module", ItemKind::Mod(..) => "module",
ItemForeignMod(..) => "foreign module", ItemKind::ForeignMod(..) => "foreign module",
ItemGlobalAsm(..) => "global asm", ItemKind::GlobalAsm(..) => "global asm",
ItemTy(..) => "type alias", ItemKind::Ty(..) => "type alias",
ItemExistential(..) => "existential type", ItemKind::Existential(..) => "existential type",
ItemEnum(..) => "enum", ItemKind::Enum(..) => "enum",
ItemStruct(..) => "struct", ItemKind::Struct(..) => "struct",
ItemUnion(..) => "union", ItemKind::Union(..) => "union",
ItemTrait(..) => "trait", ItemKind::Trait(..) => "trait",
ItemTraitAlias(..) => "trait alias", ItemKind::TraitAlias(..) => "trait alias",
ItemImpl(..) => "item", ItemKind::Impl(..) => "item",
} }
} }
pub fn adt_kind(&self) -> Option<AdtKind> { pub fn adt_kind(&self) -> Option<AdtKind> {
match *self { match *self {
ItemStruct(..) => Some(AdtKind::Struct), ItemKind::Struct(..) => Some(AdtKind::Struct),
ItemUnion(..) => Some(AdtKind::Union), ItemKind::Union(..) => Some(AdtKind::Union),
ItemEnum(..) => Some(AdtKind::Enum), ItemKind::Enum(..) => Some(AdtKind::Enum),
_ => None, _ => None,
} }
} }
pub fn generics(&self) -> Option<&Generics> { pub fn generics(&self) -> Option<&Generics> {
Some(match *self { Some(match *self {
ItemFn(_, _, ref generics, _) | ItemKind::Fn(_, _, ref generics, _) |
ItemTy(_, ref generics) | ItemKind::Ty(_, ref generics) |
ItemEnum(_, ref generics) | ItemKind::Enum(_, ref generics) |
ItemStruct(_, ref generics) | ItemKind::Struct(_, ref generics) |
ItemUnion(_, ref generics) | ItemKind::Union(_, ref generics) |
ItemTrait(_, _, ref generics, _, _) | ItemKind::Trait(_, _, ref generics, _, _) |
ItemImpl(_, _, _, ref generics, _, _, _)=> generics, ItemKind::Impl(_, _, _, ref generics, _, _, _)=> generics,
_ => return None _ => return None
}) })
} }

View File

@ -531,7 +531,7 @@ impl<'a> State<'a> {
self.print_outer_attributes(&item.attrs)?; self.print_outer_attributes(&item.attrs)?;
self.ann.pre(self, NodeItem(item))?; self.ann.pre(self, NodeItem(item))?;
match item.node { match item.node {
hir::ItemExternCrate(orig_name) => { hir::ItemKind::ExternCrate(orig_name) => {
self.head(&visibility_qualified(&item.vis, "extern crate"))?; self.head(&visibility_qualified(&item.vis, "extern crate"))?;
if let Some(orig_name) = orig_name { if let Some(orig_name) = orig_name {
self.print_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 inner head-block
self.end()?; // end outer 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.head(&visibility_qualified(&item.vis, "use"))?;
self.print_path(path, false)?; self.print_path(path, false)?;
@ -563,7 +563,7 @@ impl<'a> State<'a> {
self.end()?; // end inner head-block self.end()?; // end inner head-block
self.end()?; // end outer 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"))?; self.head(&visibility_qualified(&item.vis, "static"))?;
if m == hir::MutMutable { if m == hir::MutMutable {
self.word_space("mut")?; self.word_space("mut")?;
@ -579,7 +579,7 @@ impl<'a> State<'a> {
self.s.word(";")?; self.s.word(";")?;
self.end()?; // end the outer cbox 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.head(&visibility_qualified(&item.vis, "const"))?;
self.print_name(item.name)?; self.print_name(item.name)?;
self.word_space(":")?; self.word_space(":")?;
@ -592,7 +592,7 @@ impl<'a> State<'a> {
self.s.word(";")?; self.s.word(";")?;
self.end()?; // end the outer cbox 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.head("")?;
self.print_fn(decl, self.print_fn(decl,
header, header,
@ -606,7 +606,7 @@ impl<'a> State<'a> {
self.end()?; // need to close a box self.end()?; // need to close a box
self.ann.nested(self, Nested::Body(body))?; self.ann.nested(self, Nested::Body(body))?;
} }
hir::ItemMod(ref _mod) => { hir::ItemKind::Mod(ref _mod) => {
self.head(&visibility_qualified(&item.vis, "mod"))?; self.head(&visibility_qualified(&item.vis, "mod"))?;
self.print_name(item.name)?; self.print_name(item.name)?;
self.nbsp()?; self.nbsp()?;
@ -614,19 +614,19 @@ impl<'a> State<'a> {
self.print_mod(_mod, &item.attrs)?; self.print_mod(_mod, &item.attrs)?;
self.bclose(item.span)?; self.bclose(item.span)?;
} }
hir::ItemForeignMod(ref nmod) => { hir::ItemKind::ForeignMod(ref nmod) => {
self.head("extern")?; self.head("extern")?;
self.word_nbsp(&nmod.abi.to_string())?; self.word_nbsp(&nmod.abi.to_string())?;
self.bopen()?; self.bopen()?;
self.print_foreign_mod(nmod, &item.attrs)?; self.print_foreign_mod(nmod, &item.attrs)?;
self.bclose(item.span)?; self.bclose(item.span)?;
} }
hir::ItemGlobalAsm(ref ga) => { hir::ItemKind::GlobalAsm(ref ga) => {
self.head(&visibility_qualified(&item.vis, "global asm"))?; self.head(&visibility_qualified(&item.vis, "global asm"))?;
self.s.word(&ga.asm.as_str())?; self.s.word(&ga.asm.as_str())?;
self.end()? self.end()?
} }
hir::ItemTy(ref ty, ref generics) => { hir::ItemKind::Ty(ref ty, ref generics) => {
self.ibox(indent_unit)?; self.ibox(indent_unit)?;
self.ibox(0)?; self.ibox(0)?;
self.word_nbsp(&visibility_qualified(&item.vis, "type"))?; self.word_nbsp(&visibility_qualified(&item.vis, "type"))?;
@ -641,7 +641,7 @@ impl<'a> State<'a> {
self.s.word(";")?; self.s.word(";")?;
self.end()?; // end the outer ibox self.end()?; // end the outer ibox
} }
hir::ItemExistential(ref exist) => { hir::ItemKind::Existential(ref exist) => {
self.ibox(indent_unit)?; self.ibox(indent_unit)?;
self.ibox(0)?; self.ibox(0)?;
self.word_nbsp(&visibility_qualified(&item.vis, "existential type"))?; self.word_nbsp(&visibility_qualified(&item.vis, "existential type"))?;
@ -666,18 +666,18 @@ impl<'a> State<'a> {
self.s.word(";")?; self.s.word(";")?;
self.end()?; // end the outer ibox 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)?; 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.head(&visibility_qualified(&item.vis, "struct"))?;
self.print_struct(struct_def, generics, item.name, item.span, true)?; 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.head(&visibility_qualified(&item.vis, "union"))?;
self.print_struct(struct_def, generics, item.name, item.span, true)?; self.print_struct(struct_def, generics, item.name, item.span, true)?;
} }
hir::ItemImpl(unsafety, hir::ItemKind::Impl(unsafety,
polarity, polarity,
defaultness, defaultness,
ref generics, ref generics,
@ -722,7 +722,7 @@ impl<'a> State<'a> {
} }
self.bclose(item.span)?; 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.head("")?;
self.print_visibility(&item.vis)?; self.print_visibility(&item.vis)?;
self.print_is_auto(is_auto)?; self.print_is_auto(is_auto)?;
@ -749,7 +749,7 @@ impl<'a> State<'a> {
} }
self.bclose(item.span)?; self.bclose(item.span)?;
} }
hir::ItemTraitAlias(ref generics, ref bounds) => { hir::ItemKind::TraitAlias(ref generics, ref bounds) => {
self.head("")?; self.head("")?;
self.print_visibility(&item.vis)?; self.print_visibility(&item.vis)?;
self.word_nbsp("trait")?; self.word_nbsp("trait")?;

View File

@ -847,23 +847,23 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Item {
} }
} }
impl_stable_hash_for!(enum hir::Item_ { impl_stable_hash_for!(enum hir::ItemKind {
ItemExternCrate(orig_name), ExternCrate(orig_name),
ItemUse(path, use_kind), Use(path, use_kind),
ItemStatic(ty, mutability, body_id), Static(ty, mutability, body_id),
ItemConst(ty, body_id), Const(ty, body_id),
ItemFn(fn_decl, header, generics, body_id), Fn(fn_decl, header, generics, body_id),
ItemMod(module), Mod(module),
ItemForeignMod(foreign_mod), ForeignMod(foreign_mod),
ItemGlobalAsm(global_asm), GlobalAsm(global_asm),
ItemTy(ty, generics), Ty(ty, generics),
ItemExistential(exist), Existential(exist),
ItemEnum(enum_def, generics), Enum(enum_def, generics),
ItemStruct(variant_data, generics), Struct(variant_data, generics),
ItemUnion(variant_data, generics), Union(variant_data, generics),
ItemTrait(is_auto, unsafety, generics, bounds, item_refs), Trait(is_auto, unsafety, generics, bounds, item_refs),
ItemTraitAlias(generics, bounds), TraitAlias(generics, bounds),
ItemImpl(unsafety, impl_polarity, impl_defaultness, generics, trait_ref, ty, impl_item_refs) Impl(unsafety, impl_polarity, impl_defaultness, generics, trait_ref, ty, impl_item_refs)
}); });
impl_stable_hash_for!(struct hir::TraitItemRef { impl_stable_hash_for!(struct hir::TraitItemRef {

View File

@ -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) { 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 { 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), impl_trait_fn: Some(parent),
.. ..
}) => parent, }) => parent,

View File

@ -259,12 +259,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
fn item_scope_tag(item: &hir::Item) -> &'static str { fn item_scope_tag(item: &hir::Item) -> &'static str {
match item.node { match item.node {
hir::ItemImpl(..) => "impl", hir::ItemKind::Impl(..) => "impl",
hir::ItemStruct(..) => "struct", hir::ItemKind::Struct(..) => "struct",
hir::ItemUnion(..) => "union", hir::ItemKind::Union(..) => "union",
hir::ItemEnum(..) => "enum", hir::ItemKind::Enum(..) => "enum",
hir::ItemTrait(..) => "trait", hir::ItemKind::Trait(..) => "trait",
hir::ItemFn(..) => "function body", hir::ItemKind::Fn(..) => "function body",
_ => "item", _ => "item",
} }
} }

View File

@ -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) { if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) {
let fndecl = match self.tcx.hir.get(node_id) { let fndecl = match self.tcx.hir.get(node_id) {
hir_map::NodeItem(&hir::Item { hir_map::NodeItem(&hir::Item {
node: hir::ItemFn(ref fndecl, ..), node: hir::ItemKind::Fn(ref fndecl, ..),
.. ..
}) => &fndecl, }) => &fndecl,
hir_map::NodeTraitItem(&hir::TraitItem { hir_map::NodeTraitItem(&hir::TraitItem {

View File

@ -153,21 +153,21 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
match *node { match *node {
hir_map::NodeItem(item) => { hir_map::NodeItem(item) => {
match item.node { 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_id = self.tcx.hir.local_def_id(item.id);
let def = self.tcx.adt_def(def_id); let def = self.tcx.adt_def(def_id);
self.repr_has_repr_c = def.repr.c(); self.repr_has_repr_c = def.repr.c();
intravisit::walk_item(self, &item); intravisit::walk_item(self, &item);
} }
hir::ItemEnum(..) => { hir::ItemKind::Enum(..) => {
self.inherited_pub_visibility = item.vis.node.is_pub(); self.inherited_pub_visibility = item.vis.node.is_pub();
intravisit::walk_item(self, &item); intravisit::walk_item(self, &item);
} }
hir::ItemFn(..) hir::ItemKind::Fn(..)
| hir::ItemTy(..) | hir::ItemKind::Ty(..)
| hir::ItemStatic(..) | hir::ItemKind::Static(..)
| hir::ItemConst(..) => { | hir::ItemKind::Const(..) => {
intravisit::walk_item(self, &item); intravisit::walk_item(self, &item);
} }
_ => () _ => ()
@ -349,11 +349,11 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
self.worklist.push(item.id); self.worklist.push(item.id);
} }
match item.node { 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() self.worklist.extend(enum_def.variants.iter()
.map(|variant| variant.node.data.id())); .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 { for trait_item_ref in trait_item_refs {
let trait_item = self.krate.trait_item(trait_item_ref.id); let trait_item = self.krate.trait_item(trait_item_ref.id);
match trait_item.node { 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 { for impl_item_ref in impl_item_refs {
let impl_item = self.krate.impl_item(impl_item_ref.id); let impl_item = self.krate.impl_item(impl_item_ref.id);
if opt_trait.is_some() || 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> { fn get_struct_ctor_id(item: &hir::Item) -> Option<ast::NodeId> {
match item.node { 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()) Some(struct_def.id())
} }
_ => None _ => None
@ -454,13 +454,13 @@ struct DeadVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
fn should_warn_about_item(&mut self, item: &hir::Item) -> bool { fn should_warn_about_item(&mut self, item: &hir::Item) -> bool {
let should_warn = match item.node { let should_warn = match item.node {
hir::ItemStatic(..) hir::ItemKind::Static(..)
| hir::ItemConst(..) | hir::ItemKind::Const(..)
| hir::ItemFn(..) | hir::ItemKind::Fn(..)
| hir::ItemTy(..) | hir::ItemKind::Ty(..)
| hir::ItemEnum(..) | hir::ItemKind::Enum(..)
| hir::ItemStruct(..) | hir::ItemKind::Struct(..)
| hir::ItemUnion(..) => true, | hir::ItemKind::Union(..) => true,
_ => false _ => false
}; };
let ctor_id = get_struct_ctor_id(item); 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 // For items that have a definition with a signature followed by a
// block, point only at the signature. // block, point only at the signature.
let span = match item.node { let span = match item.node {
hir::ItemFn(..) | hir::ItemKind::Fn(..) |
hir::ItemMod(..) | hir::ItemKind::Mod(..) |
hir::ItemEnum(..) | hir::ItemKind::Enum(..) |
hir::ItemStruct(..) | hir::ItemKind::Struct(..) |
hir::ItemUnion(..) | hir::ItemKind::Union(..) |
hir::ItemTrait(..) | hir::ItemKind::Trait(..) |
hir::ItemImpl(..) => self.tcx.sess.codemap().def_span(item.span), hir::ItemKind::Impl(..) => self.tcx.sess.codemap().def_span(item.span),
_ => item.span, _ => item.span,
}; };
self.warn_dead_code( self.warn_dead_code(

View File

@ -16,7 +16,7 @@ use syntax::ast::NodeId;
use syntax::attr; use syntax::attr;
use syntax::entry::EntryPointType; use syntax::entry::EntryPointType;
use syntax_pos::Span; use syntax_pos::Span;
use hir::{Item, ItemFn, ImplItem, TraitItem}; use hir::{Item, ItemKind, ImplItem, TraitItem};
use hir::itemlikevisit::ItemLikeVisitor; use hir::itemlikevisit::ItemLikeVisitor;
struct EntryContext<'a, 'tcx: 'a> { struct EntryContext<'a, 'tcx: 'a> {
@ -91,7 +91,7 @@ pub fn find_entry_point(session: &Session,
// them in sync. // them in sync.
fn entry_point_type(item: &Item, at_root: bool) -> EntryPointType { fn entry_point_type(item: &Item, at_root: bool) -> EntryPointType {
match item.node { match item.node {
ItemFn(..) => { ItemKind::Fn(..) => {
if attr::contains_name(&item.attrs, "start") { if attr::contains_name(&item.attrs, "start") {
EntryPointType::Start EntryPointType::Start
} else if attr::contains_name(&item.attrs, "main") { } else if attr::contains_name(&item.attrs, "main") {

View File

@ -58,8 +58,8 @@ fn item_might_be_inlined(tcx: TyCtxt<'a, 'tcx, 'tcx>,
} }
match item.node { match item.node {
hir::ItemImpl(..) | hir::ItemKind::Impl(..) |
hir::ItemFn(..) => { hir::ItemKind::Fn(..) => {
let generics = tcx.generics_of(tcx.hir.local_def_id(item.id)); let generics = tcx.generics_of(tcx.hir.local_def_id(item.id));
generics_require_inlining(generics) generics_require_inlining(generics)
} }
@ -171,7 +171,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
match self.tcx.hir.find(node_id) { match self.tcx.hir.find(node_id) {
Some(hir_map::NodeItem(item)) => { Some(hir_map::NodeItem(item)) => {
match item.node { match item.node {
hir::ItemFn(..) => hir::ItemKind::Fn(..) =>
item_might_be_inlined(self.tcx, &item, self.tcx.codegen_fn_attrs(def_id)), item_might_be_inlined(self.tcx, &item, self.tcx.codegen_fn_attrs(def_id)),
_ => false, _ => false,
} }
@ -202,7 +202,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
// does too. // does too.
let impl_node_id = self.tcx.hir.as_local_node_id(impl_did).unwrap(); let impl_node_id = self.tcx.hir.as_local_node_id(impl_did).unwrap();
match self.tcx.hir.expect_item(impl_node_id).node { match self.tcx.hir.expect_item(impl_node_id).node {
hir::ItemImpl(..) => { hir::ItemKind::Impl(..) => {
let generics = self.tcx.generics_of(impl_did); let generics = self.tcx.generics_of(impl_did);
generics_require_inlining(&generics) generics_require_inlining(&generics)
} }
@ -238,7 +238,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
// If we are building an executable, only explicitly extern // If we are building an executable, only explicitly extern
// types need to be exported. // types need to be exported.
if let hir_map::NodeItem(item) = *node { 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 header.abi != Abi::Rust
} else { } else {
false false
@ -260,7 +260,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
match *node { match *node {
hir_map::NodeItem(item) => { hir_map::NodeItem(item) => {
match item.node { match item.node {
hir::ItemFn(.., body) => { hir::ItemKind::Fn(.., body) => {
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir.local_def_id(item.id);
if item_might_be_inlined(self.tcx, if item_might_be_inlined(self.tcx,
&item, &item,
@ -272,20 +272,20 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
// Reachable constants will be inlined into other crates // Reachable constants will be inlined into other crates
// unconditionally, so we need to make sure that their // unconditionally, so we need to make sure that their
// contents are also reachable. // contents are also reachable.
hir::ItemConst(_, init) => { hir::ItemKind::Const(_, init) => {
self.visit_nested_body(init); self.visit_nested_body(init);
} }
// These are normal, nothing reachable about these // These are normal, nothing reachable about these
// inherently and their children are already in the // inherently and their children are already in the
// worklist, as determined by the privacy pass // worklist, as determined by the privacy pass
hir::ItemExternCrate(_) | hir::ItemUse(..) | hir::ItemKind::ExternCrate(_) | hir::ItemKind::Use(..) |
hir::ItemExistential(..) | hir::ItemKind::Existential(..) |
hir::ItemTy(..) | hir::ItemStatic(..) | hir::ItemKind::Ty(..) | hir::ItemKind::Static(..) |
hir::ItemMod(..) | hir::ItemForeignMod(..) | hir::ItemKind::Mod(..) | hir::ItemKind::ForeignMod(..) |
hir::ItemImpl(..) | hir::ItemTrait(..) | hir::ItemTraitAlias(..) | hir::ItemKind::Impl(..) | hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..) |
hir::ItemStruct(..) | hir::ItemEnum(..) | hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..) |
hir::ItemUnion(..) | hir::ItemGlobalAsm(..) => {} hir::ItemKind::Union(..) | hir::ItemKind::GlobalAsm(..) => {}
} }
} }
hir_map::NodeTraitItem(trait_method) => { 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 // 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) { if !self.access_levels.is_reachable(item.id) {
for impl_item_ref in impl_item_refs { for impl_item_ref in impl_item_refs {
self.worklist.push(impl_item_ref.id.node_id); self.worklist.push(impl_item_ref.id.node_id);

View File

@ -476,21 +476,21 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
fn visit_item(&mut self, item: &'tcx hir::Item) { fn visit_item(&mut self, item: &'tcx hir::Item) {
match item.node { match item.node {
hir::ItemFn(ref decl, _, ref generics, _) => { hir::ItemKind::Fn(ref decl, _, ref generics, _) => {
self.visit_early_late(None, decl, generics, |this| { self.visit_early_late(None, decl, generics, |this| {
intravisit::walk_item(this, item); intravisit::walk_item(this, item);
}); });
} }
hir::ItemExternCrate(_) hir::ItemKind::ExternCrate(_)
| hir::ItemUse(..) | hir::ItemKind::Use(..)
| hir::ItemMod(..) | hir::ItemKind::Mod(..)
| hir::ItemForeignMod(..) | hir::ItemKind::ForeignMod(..)
| hir::ItemGlobalAsm(..) => { | hir::ItemKind::GlobalAsm(..) => {
// These sorts of items have no lifetime parameters at all. // These sorts of items have no lifetime parameters at all.
intravisit::walk_item(self, item); intravisit::walk_item(self, item);
} }
hir::ItemStatic(..) | hir::ItemConst(..) => { hir::ItemKind::Static(..) | hir::ItemKind::Const(..) => {
// No lifetime parameters, but implied 'static. // No lifetime parameters, but implied 'static.
let scope = Scope::Elision { let scope = Scope::Elision {
elide: Elide::Exact(Region::Static), 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)); 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 // currently existential type declarations are just generated from impl Trait
// items. doing anything on this node is irrelevant, as we currently don't need // items. doing anything on this node is irrelevant, as we currently don't need
// it. // it.
} }
hir::ItemTy(_, ref generics) hir::ItemKind::Ty(_, ref generics)
| hir::ItemExistential(hir::ExistTy { impl_trait_fn: None, ref generics, .. }) | hir::ItemKind::Existential(hir::ExistTy { impl_trait_fn: None, ref generics, .. })
| hir::ItemEnum(_, ref generics) | hir::ItemKind::Enum(_, ref generics)
| hir::ItemStruct(_, ref generics) | hir::ItemKind::Struct(_, ref generics)
| hir::ItemUnion(_, ref generics) | hir::ItemKind::Union(_, ref generics)
| hir::ItemTrait(_, _, ref generics, ..) | hir::ItemKind::Trait(_, _, ref generics, ..)
| hir::ItemTraitAlias(ref generics, ..) | hir::ItemKind::TraitAlias(ref generics, ..)
| hir::ItemImpl(_, _, _, ref generics, ..) => { | hir::ItemKind::Impl(_, _, _, ref generics, ..) => {
// Impls permit `'_` to be used and it is equivalent to "some fresh lifetime name". // Impls permit `'_` to be used and it is equivalent to "some fresh lifetime name".
// This is not true for other kinds of items.x // This is not true for other kinds of items.x
let track_lifetime_uses = match item.node { let track_lifetime_uses = match item.node {
hir::ItemImpl(..) => true, hir::ItemKind::Impl(..) => true,
_ => false, _ => false,
}; };
// These kinds of items have only early bound lifetime parameters. // 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 1 // Self comes before lifetimes
} else { } else {
0 0
@ -675,7 +675,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
// ^ ^ this gets resolved in the scope of // ^ ^ this gets resolved in the scope of
// the exist_ty generics // the exist_ty generics
let (generics, bounds) = match self.tcx.hir.expect_item(id).node { 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, generics,
bounds, bounds,
), ),
@ -1208,11 +1208,11 @@ fn compute_object_lifetime_defaults(
let mut map = NodeMap(); let mut map = NodeMap();
for item in tcx.hir.krate().items.values() { for item in tcx.hir.krate().items.values() {
match item.node { match item.node {
hir::ItemStruct(_, ref generics) hir::ItemKind::Struct(_, ref generics)
| hir::ItemUnion(_, ref generics) | hir::ItemKind::Union(_, ref generics)
| hir::ItemEnum(_, ref generics) | hir::ItemKind::Enum(_, ref generics)
| hir::ItemTy(_, ref generics) | hir::ItemKind::Ty(_, ref generics)
| hir::ItemTrait(_, _, ref generics, ..) => { | hir::ItemKind::Trait(_, _, ref generics, ..) => {
let result = object_lifetime_defaults_for_item(tcx, generics); let result = object_lifetime_defaults_for_item(tcx, generics);
// Debugging aid. // Debugging aid.
@ -1485,12 +1485,12 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
let mut index = 0; let mut index = 0;
if let Some(parent_id) = parent_id { if let Some(parent_id) = parent_id {
let parent = self.tcx.hir.expect_item(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. index += 1; // Self comes first.
} }
match parent.node { match parent.node {
hir::ItemTrait(_, _, ref generics, ..) hir::ItemKind::Trait(_, _, ref generics, ..)
| hir::ItemImpl(_, _, _, ref generics, ..) => { | hir::ItemKind::Impl(_, _, _, ref generics, ..) => {
index += generics.params.len() as u32; 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); let fn_id = self.tcx.hir.body_owner(body_id);
match self.tcx.hir.get(fn_id) { match self.tcx.hir.get(fn_id) {
hir::map::NodeItem(&hir::Item { hir::map::NodeItem(&hir::Item {
node: hir::ItemFn(..), node: hir::ItemKind::Fn(..),
.. ..
}) })
| hir::map::NodeTraitItem(&hir::TraitItem { | hir::map::NodeTraitItem(&hir::TraitItem {
@ -1834,7 +1834,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
let body = match self.tcx.hir.get(parent) { let body = match self.tcx.hir.get(parent) {
// `fn` definitions and methods. // `fn` definitions and methods.
hir::map::NodeItem(&hir::Item { hir::map::NodeItem(&hir::Item {
node: hir::ItemFn(.., body), node: hir::ItemKind::Fn(.., body),
.. ..
}) => Some(body), }) => Some(body),
@ -1847,7 +1847,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
.expect_item(self.tcx.hir.get_parent(parent)) .expect_item(self.tcx.hir.get_parent(parent))
.node .node
{ {
hir::ItemTrait(.., ref trait_items) => { hir::ItemKind::Trait(.., ref trait_items) => {
assoc_item_kind = trait_items assoc_item_kind = trait_items
.iter() .iter()
.find(|ti| ti.id.node_id == parent) .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)) .expect_item(self.tcx.hir.get_parent(parent))
.node .node
{ {
hir::ItemImpl(.., ref self_ty, ref impl_items) => { hir::ItemKind::Impl(.., ref self_ty, ref impl_items) => {
impl_self = Some(self_ty); impl_self = Some(self_ty);
assoc_item_kind = impl_items assoc_item_kind = impl_items
.iter() .iter()

View File

@ -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 // 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 // and propagate this unstability to children, but this annotation is completely
// optional. They inherit stability from their parents when unannotated. // 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; self.in_trait_impl = false;
kind = AnnotationKind::Container; kind = AnnotationKind::Container;
} }
hir::ItemImpl(.., Some(_), _, _) => { hir::ItemKind::Impl(.., Some(_), _, _) => {
self.in_trait_impl = true; self.in_trait_impl = true;
} }
hir::ItemStruct(ref sd, _) => { hir::ItemKind::Struct(ref sd, _) => {
if !sd.is_struct() { if !sd.is_struct() {
self.annotate(sd.id(), &i.attrs, i.span, AnnotationKind::Required, |_| {}) 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 // 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 // and propagate this unstability to children, but this annotation is completely
// optional. They inherit stability from their parents when unannotated. // 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) _ => 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) { fn visit_item(&mut self, item: &'tcx hir::Item) {
match item.node { match item.node {
hir::ItemExternCrate(_) => { hir::ItemKind::ExternCrate(_) => {
// compiler-generated `extern crate` items have a dummy span. // compiler-generated `extern crate` items have a dummy span.
if item.span.is_dummy() { return } 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 // For implementations of traits, check the stability of each item
// individually as it's possible to have a stable trait with unstable // individually as it's possible to have a stable trait with unstable
// items. // 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 { if let Def::Trait(trait_did) = t.path.def {
for impl_item_ref in impl_item_refs { for impl_item_ref in impl_item_refs {
let impl_item = self.tcx.hir.impl_item(impl_item_ref.id); 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, // There's no good place to insert stability check for non-Copy unions,
// so semi-randomly perform it here in stability.rs // 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 def_id = self.tcx.hir.local_def_id(item.id);
let adt_def = self.tcx.adt_def(def_id); let adt_def = self.tcx.adt_def(def_id);
let ty = self.tcx.type_of(def_id); let ty = self.tcx.type_of(def_id);

View File

@ -955,7 +955,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
} }
hir::map::NodeItem(&hir::Item { hir::map::NodeItem(&hir::Item {
span, span,
node: hir::ItemFn(ref decl, ..), node: hir::ItemKind::Fn(ref decl, ..),
.. ..
}) | }) |
hir::map::NodeImplItem(&hir::ImplItem { hir::map::NodeImplItem(&hir::ImplItem {

View File

@ -534,7 +534,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
match self.hir.as_local_node_id(node_item_def_id) { match self.hir.as_local_node_id(node_item_def_id) {
Some(node_id) => { Some(node_id) => {
let item = self.hir.expect_item(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() defaultness.is_default()
} else { } else {
false false

View File

@ -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_def_id = tcx.hir.local_def_id(parent_id);
let parent_item = tcx.hir.expect_item(parent_id); let parent_item = tcx.hir.expect_item(parent_id);
match parent_item.node { 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) { 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, let assoc_item = tcx.associated_item_from_impl_item_ref(parent_def_id,
impl_item_ref); 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) { 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, let assoc_item = tcx.associated_item_from_trait_item_ref(parent_def_id,
&parent_item.vis, &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 id = tcx.hir.as_local_node_id(def_id).unwrap();
let item = tcx.hir.expect_item(id); let item = tcx.hir.expect_item(id);
let vec: Vec<_> = match item.node { let vec: Vec<_> = match item.node {
hir::ItemTrait(.., ref trait_item_refs) => { hir::ItemKind::Trait(.., ref trait_item_refs) => {
trait_item_refs.iter() trait_item_refs.iter()
.map(|trait_item_ref| trait_item_ref.id) .map(|trait_item_ref| trait_item_ref.id)
.map(|id| tcx.hir.local_def_id(id.node_id)) .map(|id| tcx.hir.local_def_id(id.node_id))
.collect() .collect()
} }
hir::ItemImpl(.., ref impl_item_refs) => { hir::ItemKind::Impl(.., ref impl_item_refs) => {
impl_item_refs.iter() impl_item_refs.iter()
.map(|impl_item_ref| impl_item_ref.id) .map(|impl_item_ref| impl_item_ref.id)
.map(|id| tcx.hir.local_def_id(id.node_id)) .map(|id| tcx.hir.local_def_id(id.node_id))
.collect() .collect()
} }
hir::ItemTraitAlias(..) => vec![], hir::ItemKind::TraitAlias(..) => vec![],
_ => span_bug!(item.span, "associated_item_def_ids: not impl or trait") _ => span_bug!(item.span, "associated_item_def_ids: not impl or trait")
}; };
Lrc::new(vec) Lrc::new(vec)

View File

@ -605,7 +605,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
if let Some(node) = self.hir.get_if_local(def_id) { if let Some(node) = self.hir.get_if_local(def_id) {
match node { match node {
Node::NodeItem(&hir::Item { Node::NodeItem(&hir::Item {
node: hir::ItemStatic(_, mutbl, _), .. node: hir::ItemKind::Static(_, mutbl, _), ..
}) => Some(mutbl), }) => Some(mutbl),
Node::NodeForeignItem(&hir::ForeignItem { Node::NodeForeignItem(&hir::ForeignItem {
node: hir::ForeignItemKind::Static(_, is_mutbl), .. node: hir::ForeignItemKind::Static(_, is_mutbl), ..

View File

@ -105,11 +105,11 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// Only consider nodes that actually have exported symbols. // Only consider nodes that actually have exported symbols.
hir::map::NodeItem(&hir::Item { hir::map::NodeItem(&hir::Item {
node: hir::ItemStatic(..), node: hir::ItemKind::Static(..),
.. ..
}) | }) |
hir::map::NodeItem(&hir::Item { hir::map::NodeItem(&hir::Item {
node: hir::ItemFn(..), .. node: hir::ItemKind::Fn(..), ..
}) | }) |
hir::map::NodeImplItem(&hir::ImplItem { hir::map::NodeImplItem(&hir::ImplItem {
node: hir::ImplItemKind::Method(..), node: hir::ImplItemKind::Method(..),

View File

@ -125,7 +125,7 @@ pub fn get_static(cx: &CodegenCx, def_id: DefId) -> ValueRef {
let llty = cx.layout_of(ty).llvm_type(cx); let llty = cx.layout_of(ty).llvm_type(cx);
let (g, attrs) = match cx.tcx.hir.get(id) { let (g, attrs) = match cx.tcx.hir.get(id) {
hir_map::NodeItem(&hir::Item { 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() { if declare::get_declared_value(cx, &sym[..]).is_some() {
span_bug!(span, "Conflicting symbol names for static?"); span_bug!(span, "Conflicting symbol names for static?");

View File

@ -60,7 +60,7 @@ pub trait MonoItemExt<'a, 'tcx>: fmt::Debug + BaseMonoItemExt<'a, 'tcx> {
} }
MonoItem::GlobalAsm(node_id) => { MonoItem::GlobalAsm(node_id) => {
let item = cx.tcx.hir.expect_item(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); asm::codegen_global_asm(cx, ga);
} else { } else {
span_bug!(item.span, "Mismatch between hir::Item type and MonoItem type") span_bug!(item.span, "Mismatch between hir::Item type and MonoItem type")

View File

@ -249,24 +249,24 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
} }
return match it.node { return match it.node {
hir::ItemUse(..) | hir::ItemKind::Use(..) |
hir::ItemExternCrate(..) | hir::ItemKind::ExternCrate(..) |
hir::ItemConst(..) | hir::ItemKind::Const(..) |
hir::ItemStatic(..) | hir::ItemKind::Static(..) |
hir::ItemFn(..) | hir::ItemKind::Fn(..) |
hir::ItemForeignMod(..) | hir::ItemKind::ForeignMod(..) |
hir::ItemGlobalAsm(..) | hir::ItemKind::GlobalAsm(..) |
hir::ItemExistential(..) | hir::ItemKind::Existential(..) |
hir::ItemTy(..) => None, hir::ItemKind::Ty(..) => None,
hir::ItemEnum(..) | hir::ItemKind::Enum(..) |
hir::ItemStruct(..) | hir::ItemKind::Struct(..) |
hir::ItemUnion(..) | hir::ItemKind::Union(..) |
hir::ItemTrait(..) | hir::ItemKind::Trait(..) |
hir::ItemTraitAlias(..) | hir::ItemKind::TraitAlias(..) |
hir::ItemImpl(..) => None, hir::ItemKind::Impl(..) => None,
hir::ItemMod(ref m) => search_mod(this, m, idx, names), hir::ItemKind::Mod(ref m) => search_mod(this, m, idx, names),
}; };
} }
} }

View File

@ -29,7 +29,7 @@ use std::iter::FromIterator;
use std::vec::Vec; use std::vec::Vec;
use rustc::dep_graph::{DepNode, label_strs}; use rustc::dep_graph::{DepNode, label_strs};
use rustc::hir; 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::map::Node as HirNode;
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir::itemlikevisit::ItemLikeVisitor;
@ -342,40 +342,40 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
// FIXME(michaelwoerister): do commented out ones // FIXME(michaelwoerister): do commented out ones
// // An `extern crate` item, with optional original crate name, // // 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;` // // `use foo::bar::*;` or `use foo::bar::baz as quux;`
// HirItem::ItemUse(..), // intentionally no assertions // HirItem::Use(..), // intentionally no assertions
// A `static` item // A `static` item
HirItem::ItemStatic(..) => ("ItemStatic", LABELS_CONST), HirItem::Static(..) => ("ItemStatic", LABELS_CONST),
// A `const` item // A `const` item
HirItem::ItemConst(..) => ("ItemConst", LABELS_CONST), HirItem::Const(..) => ("ItemConst", LABELS_CONST),
// A function declaration // A function declaration
HirItem::ItemFn(..) => ("ItemFn", LABELS_FN), HirItem::Fn(..) => ("ItemFn", LABELS_FN),
// // A module // // A module
HirItem::ItemMod(..) =>("ItemMod", LABELS_HIR_ONLY), HirItem::Mod(..) =>("ItemMod", LABELS_HIR_ONLY),
// // An external module // // An external module
HirItem::ItemForeignMod(..) => ("ItemForeignMod", LABELS_HIR_ONLY), HirItem::ForeignMod(..) => ("ItemForeignMod", LABELS_HIR_ONLY),
// Module-level inline assembly (from global_asm!) // 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>` // 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>}` // 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}` // 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}` // 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 // Represents a Trait Declaration
// FIXME(michaelwoerister): trait declaration is buggy because sometimes some of // 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. // However, this did not seem to work effectively and more bugs were hit.
// Nebie @vitiral gave up :) // Nebie @vitiral gave up :)
// //
//HirItem::ItemTrait(..) => ("ItemTrait", LABELS_TRAIT), //HirItem::Trait(..) => ("ItemTrait", LABELS_TRAIT),
// An implementation, eg `impl<A> Trait for Foo { .. }` // An implementation, eg `impl<A> Trait for Foo { .. }`
HirItem::ItemImpl(..) => ("ItemImpl", LABELS_IMPL), HirItem::Impl(..) => ("ItemImpl", LABELS_IMPL),
_ => self.tcx.sess.span_fatal( _ => self.tcx.sess.span_fatal(
attr.span, attr.span,

View File

@ -133,11 +133,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCamelCaseTypes {
} }
match it.node { match it.node {
hir::ItemTy(..) | hir::ItemKind::Ty(..) |
hir::ItemEnum(..) | hir::ItemKind::Enum(..) |
hir::ItemStruct(..) | hir::ItemKind::Struct(..) |
hir::ItemUnion(..) => self.check_case(cx, "type", it.name, it.span), hir::ItemKind::Union(..) => self.check_case(cx, "type", it.name, it.span),
hir::ItemTrait(..) => self.check_case(cx, "trait", 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) { 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)); 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 { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
match it.node { match it.node {
hir::ItemStatic(..) => { hir::ItemKind::Static(..) => {
if attr::find_by_name(&it.attrs, "no_mangle").is_some() { if attr::find_by_name(&it.attrs, "no_mangle").is_some() {
return; return;
} }
NonUpperCaseGlobals::check_upper_case(cx, "static variable", it.name, it.span); 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); NonUpperCaseGlobals::check_upper_case(cx, "constant", it.name, it.span);
} }
_ => {} _ => {}

View File

@ -120,11 +120,11 @@ impl LintPass for BoxPointers {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
match it.node { match it.node {
hir::ItemFn(..) | hir::ItemKind::Fn(..) |
hir::ItemTy(..) | hir::ItemKind::Ty(..) |
hir::ItemEnum(..) | hir::ItemKind::Enum(..) |
hir::ItemStruct(..) | hir::ItemKind::Struct(..) |
hir::ItemUnion(..) => { hir::ItemKind::Union(..) => {
let def_id = cx.tcx.hir.local_def_id(it.id); let def_id = cx.tcx.hir.local_def_id(it.id);
self.check_heap_type(cx, it.span, cx.tcx.type_of(def_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 // If it's a struct, we also have to check the fields' types
match it.node { match it.node {
hir::ItemStruct(ref struct_def, _) | hir::ItemKind::Struct(ref struct_def, _) |
hir::ItemUnion(ref struct_def, _) => { hir::ItemKind::Union(ref struct_def, _) => {
for struct_field in struct_def.fields() { for struct_field in struct_def.fields() {
let def_id = cx.tcx.hir.local_def_id(struct_field.id); let def_id = cx.tcx.hir.local_def_id(struct_field.id);
self.check_heap_type(cx, struct_field.span, 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) { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
match it.node { 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") 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") 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) { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
let desc = match it.node { let desc = match it.node {
hir::ItemFn(..) => "a function", hir::ItemKind::Fn(..) => "a function",
hir::ItemMod(..) => "a module", hir::ItemKind::Mod(..) => "a module",
hir::ItemEnum(..) => "an enum", hir::ItemKind::Enum(..) => "an enum",
hir::ItemStruct(..) => "a struct", hir::ItemKind::Struct(..) => "a struct",
hir::ItemUnion(..) => "a union", hir::ItemKind::Union(..) => "a union",
hir::ItemTrait(.., ref trait_item_refs) => { hir::ItemKind::Trait(.., ref trait_item_refs) => {
// Issue #11592, traits are always considered exported, even when private. // Issue #11592, traits are always considered exported, even when private.
if let hir::VisibilityKind::Inherited = it.vis.node { if let hir::VisibilityKind::Inherited = it.vis.node {
self.private_traits.insert(it.id); self.private_traits.insert(it.id);
@ -406,8 +406,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
} }
"a trait" "a trait"
} }
hir::ItemTy(..) => "a type alias", hir::ItemKind::Ty(..) => "a type alias",
hir::ItemImpl(.., Some(ref trait_ref), _, ref impl_item_refs) => { 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 // If the trait is private, add the impl items to private_traits so they don't get
// reported for missing docs. // reported for missing docs.
let real_trait = trait_ref.path.def.def_id(); let real_trait = trait_ref.path.def.def_id();
@ -425,8 +425,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
} }
return; return;
} }
hir::ItemConst(..) => "a constant", hir::ItemKind::Const(..) => "a constant",
hir::ItemStatic(..) => "a static", hir::ItemKind::Static(..) => "a static",
_ => return, _ => return,
}; };
@ -509,21 +509,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
return; return;
} }
let (def, ty) = match item.node { let (def, ty) = match item.node {
hir::ItemStruct(_, ref ast_generics) => { hir::ItemKind::Struct(_, ref ast_generics) => {
if !ast_generics.params.is_empty() { if !ast_generics.params.is_empty() {
return; return;
} }
let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id)); let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id));
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[]))) (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() { if !ast_generics.params.is_empty() {
return; return;
} }
let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id)); let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id));
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[]))) (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() { if !ast_generics.params.is_empty() {
return; return;
} }
@ -577,9 +577,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
} }
match item.node { match item.node {
hir::ItemStruct(..) | hir::ItemKind::Struct(..) |
hir::ItemUnion(..) | hir::ItemKind::Union(..) |
hir::ItemEnum(..) => {} hir::ItemKind::Enum(..) => {}
_ => return, _ => return,
} }
@ -1121,7 +1121,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
} }
match it.node { match it.node {
hir::ItemExternCrate(..) => (), hir::ItemKind::ExternCrate(..) => (),
_ => return, _ => return,
}; };
@ -1203,7 +1203,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
}; };
match it.node { 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 let Some(no_mangle_attr) = attr::find_by_name(&it.attrs, "no_mangle") {
if attr::contains_name(&it.attrs, "linkage") { if attr::contains_name(&it.attrs, "linkage") {
return; 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") && if attr::contains_name(&it.attrs, "no_mangle") &&
!cx.access_levels.is_reachable(it.id) { !cx.access_levels.is_reachable(it.id) {
let msg = "static is marked #[no_mangle], but not exported"; let msg = "static is marked #[no_mangle], but not exported";
@ -1241,7 +1241,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
err.emit(); err.emit();
} }
} }
hir::ItemConst(..) => { hir::ItemKind::Const(..) => {
if attr::contains_name(&it.attrs, "no_mangle") { if attr::contains_name(&it.attrs, "no_mangle") {
// Const items do not refer to a particular location in memory, and therefore // Const items do not refer to a particular location in memory, and therefore
// don't have anything to attach a symbol to // 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 { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
fn check_item(&mut self, ctx: &LateContext, item: &hir::Item) { 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() { for field in vdata.fields() {
let field_ty = ctx.tcx.type_of(ctx.tcx.hir.local_def_id(field.id)); 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) { if field_ty.needs_drop(ctx.tcx, ctx.param_env) {
@ -1523,7 +1523,7 @@ impl TypeAliasBounds {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds {
fn check_item(&mut self, cx: &LateContext, item: &hir::Item) { fn check_item(&mut self, cx: &LateContext, item: &hir::Item) {
let (ty, type_alias_generics) = match item.node { 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, _ => return,
}; };
let mut suggested_changing_assoc_types = false; 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 { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedBrokenConst {
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
match it.node { match it.node {
hir::ItemConst(_, body_id) => { hir::ItemKind::Const(_, body_id) => {
check_const(cx, body_id, "constant"); 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), &mut UnusedBrokenConstVisitor(cx),
ty ty
), ),
@ -1761,12 +1761,12 @@ impl LintPass for UnnameableTestFunctions {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnameableTestFunctions { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnameableTestFunctions {
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
match it.node { match it.node {
hir::ItemFn(..) => { hir::ItemKind::Fn(..) => {
for attr in &it.attrs { for attr in &it.attrs {
if attr.name() == "test" { if attr.name() == "test" {
let parent = cx.tcx.hir.get_parent(it.id); let parent = cx.tcx.hir.get_parent(it.id);
match cx.tcx.hir.find(parent) { 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 => {} None => {}
_ => { _ => {
cx.struct_span_lint( cx.struct_span_lint(

View File

@ -782,7 +782,7 @@ impl LintPass for ImproperCTypes {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes {
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
let mut vis = ImproperCTypesVisitor { cx: cx }; 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 { if nmod.abi != Abi::RustIntrinsic && nmod.abi != Abi::PlatformIntrinsic {
for ni in &nmod.items { for ni in &nmod.items {
match ni.node { match ni.node {
@ -810,7 +810,7 @@ impl LintPass for VariantSizeDifferences {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { 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 item_def_id = cx.tcx.hir.local_def_id(it.id);
let generics = cx.tcx.generics_of(item_def_id); let generics = cx.tcx.generics_of(item_def_id);
for param in &generics.params { for param in &generics.params {

View File

@ -1039,16 +1039,16 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
debug!("IsolatedEncoder::encode_info_for_item({:?})", def_id); debug!("IsolatedEncoder::encode_info_for_item({:?})", def_id);
let kind = match item.node { let kind = match item.node {
hir::ItemStatic(_, hir::MutMutable, _) => EntryKind::MutStatic, hir::ItemKind::Static(_, hir::MutMutable, _) => EntryKind::MutStatic,
hir::ItemStatic(_, hir::MutImmutable, _) => EntryKind::ImmStatic, hir::ItemKind::Static(_, hir::MutImmutable, _) => EntryKind::ImmStatic,
hir::ItemConst(_, body_id) => { hir::ItemKind::Const(_, body_id) => {
let mir = tcx.at(item.span).mir_const_qualif(def_id).0; let mir = tcx.at(item.span).mir_const_qualif(def_id).0;
EntryKind::Const( EntryKind::Const(
self.const_qualif(mir, body_id), self.const_qualif(mir, body_id),
self.encode_rendered_const_for_body(body_id) self.encode_rendered_const_for_body(body_id)
) )
} }
hir::ItemFn(_, header, .., body) => { hir::ItemKind::Fn(_, header, .., body) => {
let data = FnData { let data = FnData {
constness: header.constness, constness: header.constness,
arg_names: self.encode_fn_arg_names_for_body(body), 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)) 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))); return self.encode_info_for_mod(FromId(item.id, (m, &item.attrs, &item.vis)));
} }
hir::ItemForeignMod(_) => EntryKind::ForeignMod, hir::ItemKind::ForeignMod(_) => EntryKind::ForeignMod,
hir::ItemGlobalAsm(..) => EntryKind::GlobalAsm, hir::ItemKind::GlobalAsm(..) => EntryKind::GlobalAsm,
hir::ItemTy(..) => EntryKind::Type, hir::ItemKind::Ty(..) => EntryKind::Type,
hir::ItemExistential(..) => EntryKind::Existential, hir::ItemKind::Existential(..) => EntryKind::Existential,
hir::ItemEnum(..) => EntryKind::Enum(get_repr_options(&tcx, def_id)), hir::ItemKind::Enum(..) => EntryKind::Enum(get_repr_options(&tcx, def_id)),
hir::ItemStruct(ref struct_def, _) => { hir::ItemKind::Struct(ref struct_def, _) => {
let variant = tcx.adt_def(def_id).non_enum_variant(); let variant = tcx.adt_def(def_id).non_enum_variant();
// Encode def_ids for each field and method // 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, ctor_sig: None,
}), repr_options) }), repr_options)
} }
hir::ItemUnion(..) => { hir::ItemKind::Union(..) => {
let variant = tcx.adt_def(def_id).non_enum_variant(); let variant = tcx.adt_def(def_id).non_enum_variant();
let repr_options = get_repr_options(&tcx, def_id); 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, ctor_sig: None,
}), repr_options) }), repr_options)
} }
hir::ItemImpl(_, polarity, defaultness, ..) => { hir::ItemKind::Impl(_, polarity, defaultness, ..) => {
let trait_ref = tcx.impl_trait_ref(def_id); let trait_ref = tcx.impl_trait_ref(def_id);
let parent = if let Some(trait_ref) = trait_ref { let parent = if let Some(trait_ref) = trait_ref {
let trait_def = tcx.trait_def(trait_ref.def_id); 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)) EntryKind::Impl(self.lazy(&data))
} }
hir::ItemTrait(..) => { hir::ItemKind::Trait(..) => {
let trait_def = tcx.trait_def(def_id); let trait_def = tcx.trait_def(def_id);
let data = TraitData { let data = TraitData {
unsafety: trait_def.unsafety, unsafety: trait_def.unsafety,
@ -1143,9 +1143,9 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
EntryKind::Trait(self.lazy(&data)) EntryKind::Trait(self.lazy(&data))
} }
hir::ItemExternCrate(_) | hir::ItemKind::ExternCrate(_) |
hir::ItemTraitAlias(..) | hir::ItemKind::TraitAlias(..) |
hir::ItemUse(..) => bug!("cannot encode info for item {:?}", item), hir::ItemKind::Use(..) => bug!("cannot encode info for item {:?}", item),
}; };
Entry { Entry {
@ -1154,28 +1154,28 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
span: self.lazy(&item.span), span: self.lazy(&item.span),
attributes: self.encode_attributes(&item.attrs), attributes: self.encode_attributes(&item.attrs),
children: match item.node { children: match item.node {
hir::ItemForeignMod(ref fm) => { hir::ItemKind::ForeignMod(ref fm) => {
self.lazy_seq(fm.items self.lazy_seq(fm.items
.iter() .iter()
.map(|foreign_item| tcx.hir.local_def_id(foreign_item.id).index)) .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); let def = self.tcx.adt_def(def_id);
self.lazy_seq(def.variants.iter().map(|v| { self.lazy_seq(def.variants.iter().map(|v| {
assert!(v.did.is_local()); assert!(v.did.is_local());
v.did.index v.did.index
})) }))
} }
hir::ItemStruct(..) | hir::ItemKind::Struct(..) |
hir::ItemUnion(..) => { hir::ItemKind::Union(..) => {
let def = self.tcx.adt_def(def_id); let def = self.tcx.adt_def(def_id);
self.lazy_seq(def.non_enum_variant().fields.iter().map(|f| { self.lazy_seq(def.non_enum_variant().fields.iter().map(|f| {
assert!(f.did.is_local()); assert!(f.did.is_local());
f.did.index f.did.index
})) }))
} }
hir::ItemImpl(..) | hir::ItemKind::Impl(..) |
hir::ItemTrait(..) => { hir::ItemKind::Trait(..) => {
self.lazy_seq(tcx.associated_item_def_ids(def_id).iter().map(|&def_id| { self.lazy_seq(tcx.associated_item_def_ids(def_id).iter().map(|&def_id| {
assert!(def_id.is_local()); assert!(def_id.is_local());
def_id.index def_id.index
@ -1187,49 +1187,49 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
deprecation: self.encode_deprecation(def_id), deprecation: self.encode_deprecation(def_id),
ty: match item.node { ty: match item.node {
hir::ItemStatic(..) | hir::ItemKind::Static(..) |
hir::ItemConst(..) | hir::ItemKind::Const(..) |
hir::ItemFn(..) | hir::ItemKind::Fn(..) |
hir::ItemTy(..) | hir::ItemKind::Ty(..) |
hir::ItemExistential(..) | hir::ItemKind::Existential(..) |
hir::ItemEnum(..) | hir::ItemKind::Enum(..) |
hir::ItemStruct(..) | hir::ItemKind::Struct(..) |
hir::ItemUnion(..) | hir::ItemKind::Union(..) |
hir::ItemImpl(..) => Some(self.encode_item_type(def_id)), hir::ItemKind::Impl(..) => Some(self.encode_item_type(def_id)),
_ => None, _ => None,
}, },
inherent_impls: self.encode_inherent_implementations(def_id), inherent_impls: self.encode_inherent_implementations(def_id),
variances: match item.node { variances: match item.node {
hir::ItemEnum(..) | hir::ItemKind::Enum(..) |
hir::ItemStruct(..) | hir::ItemKind::Struct(..) |
hir::ItemUnion(..) | hir::ItemKind::Union(..) |
hir::ItemFn(..) => self.encode_variances_of(def_id), hir::ItemKind::Fn(..) => self.encode_variances_of(def_id),
_ => LazySeq::empty(), _ => LazySeq::empty(),
}, },
generics: match item.node { generics: match item.node {
hir::ItemStatic(..) | hir::ItemKind::Static(..) |
hir::ItemConst(..) | hir::ItemKind::Const(..) |
hir::ItemFn(..) | hir::ItemKind::Fn(..) |
hir::ItemTy(..) | hir::ItemKind::Ty(..) |
hir::ItemEnum(..) | hir::ItemKind::Enum(..) |
hir::ItemStruct(..) | hir::ItemKind::Struct(..) |
hir::ItemUnion(..) | hir::ItemKind::Union(..) |
hir::ItemImpl(..) | hir::ItemKind::Impl(..) |
hir::ItemExistential(..) | hir::ItemKind::Existential(..) |
hir::ItemTrait(..) => Some(self.encode_generics(def_id)), hir::ItemKind::Trait(..) => Some(self.encode_generics(def_id)),
_ => None, _ => None,
}, },
predicates: match item.node { predicates: match item.node {
hir::ItemStatic(..) | hir::ItemKind::Static(..) |
hir::ItemConst(..) | hir::ItemKind::Const(..) |
hir::ItemFn(..) | hir::ItemKind::Fn(..) |
hir::ItemTy(..) | hir::ItemKind::Ty(..) |
hir::ItemEnum(..) | hir::ItemKind::Enum(..) |
hir::ItemStruct(..) | hir::ItemKind::Struct(..) |
hir::ItemUnion(..) | hir::ItemKind::Union(..) |
hir::ItemImpl(..) | hir::ItemKind::Impl(..) |
hir::ItemExistential(..) | hir::ItemKind::Existential(..) |
hir::ItemTrait(..) => Some(self.encode_predicates(def_id)), hir::ItemKind::Trait(..) => Some(self.encode_predicates(def_id)),
_ => None, _ => 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 // hack. (No reason not to expand it in the future if
// necessary.) // necessary.)
predicates_defined_on: match item.node { 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 _ => None, // not *wrong* for other kinds of items, but not needed
}, },
mir: match item.node { mir: match item.node {
hir::ItemStatic(..) => { hir::ItemKind::Static(..) => {
self.encode_optimized_mir(def_id) self.encode_optimized_mir(def_id)
} }
hir::ItemConst(..) => self.encode_optimized_mir(def_id), hir::ItemKind::Const(..) => self.encode_optimized_mir(def_id),
hir::ItemFn(_, header, ..) => { hir::ItemKind::Fn(_, header, ..) => {
let generics = tcx.generics_of(def_id); let generics = tcx.generics_of(def_id);
let has_types = generics.params.iter().any(|param| match param.kind { let has_types = generics.params.iter().any(|param| match param.kind {
ty::GenericParamDefKind::Type { .. } => true, ty::GenericParamDefKind::Type { .. } => true,
@ -1614,8 +1614,8 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
intravisit::walk_item(self, item); intravisit::walk_item(self, item);
let def_id = self.index.tcx.hir.local_def_id(item.id); let def_id = self.index.tcx.hir.local_def_id(item.id);
match item.node { match item.node {
hir::ItemExternCrate(_) | hir::ItemKind::ExternCrate(_) |
hir::ItemUse(..) => (), // ignore these hir::ItemKind::Use(..) => (), // ignore these
_ => self.index.record(def_id, IsolatedEncoder::encode_info_for_item, (def_id, item)), _ => self.index.record(def_id, IsolatedEncoder::encode_info_for_item, (def_id, item)),
} }
self.index.encode_addl_info_for_item(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) { fn encode_addl_info_for_item(&mut self, item: &hir::Item) {
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir.local_def_id(item.id);
match item.node { match item.node {
hir::ItemStatic(..) | hir::ItemKind::Static(..) |
hir::ItemConst(..) | hir::ItemKind::Const(..) |
hir::ItemFn(..) | hir::ItemKind::Fn(..) |
hir::ItemMod(..) | hir::ItemKind::Mod(..) |
hir::ItemForeignMod(..) | hir::ItemKind::ForeignMod(..) |
hir::ItemGlobalAsm(..) | hir::ItemKind::GlobalAsm(..) |
hir::ItemExternCrate(..) | hir::ItemKind::ExternCrate(..) |
hir::ItemUse(..) | hir::ItemKind::Use(..) |
hir::ItemTy(..) | hir::ItemKind::Ty(..) |
hir::ItemExistential(..) | hir::ItemKind::Existential(..) |
hir::ItemTraitAlias(..) => { hir::ItemKind::TraitAlias(..) => {
// no sub-item recording needed in these cases // no sub-item recording needed in these cases
} }
hir::ItemEnum(..) => { hir::ItemKind::Enum(..) => {
self.encode_fields(def_id); self.encode_fields(def_id);
let def = self.tcx.adt_def(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))); (def_id, Untracked(i)));
} }
} }
hir::ItemStruct(ref struct_def, _) => { hir::ItemKind::Struct(ref struct_def, _) => {
self.encode_fields(def_id); self.encode_fields(def_id);
// If the struct has a constructor, encode it. // 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)); (def_id, ctor_def_id));
} }
} }
hir::ItemUnion(..) => { hir::ItemKind::Union(..) => {
self.encode_fields(def_id); 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() { for &trait_item_def_id in self.tcx.associated_item_def_ids(def_id).iter() {
self.record(trait_item_def_id, self.record(trait_item_def_id,
IsolatedEncoder::encode_info_for_impl_item, IsolatedEncoder::encode_info_for_impl_item,
trait_item_def_id); trait_item_def_id);
} }
} }
hir::ItemTrait(..) => { hir::ItemKind::Trait(..) => {
for &item_def_id in self.tcx.associated_item_def_ids(def_id).iter() { for &item_def_id in self.tcx.associated_item_def_ids(def_id).iter() {
self.record(item_def_id, self.record(item_def_id,
IsolatedEncoder::encode_info_for_trait_item, 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> { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'a, 'tcx> {
fn visit_item(&mut self, item: &hir::Item) { 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); let impl_id = self.tcx.hir.local_def_id(item.id);
if let Some(trait_ref) = self.tcx.impl_trait_ref(impl_id) { if let Some(trait_ref) = self.tcx.impl_trait_ref(impl_id) {
self.impls self.impls

View File

@ -30,7 +30,7 @@ struct Collector<'a, 'tcx: 'a> {
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> {
fn visit_item(&mut self, it: &'tcx hir::Item) { fn visit_item(&mut self, it: &'tcx hir::Item) {
let fm = match it.node { let fm = match it.node {
hir::ItemForeignMod(ref fm) => fm, hir::ItemKind::ForeignMod(ref fm) => fm,
_ => return, _ => return,
}; };

View File

@ -37,7 +37,7 @@ struct Collector {
impl<'tcx> ItemLikeVisitor<'tcx> for Collector { impl<'tcx> ItemLikeVisitor<'tcx> for Collector {
fn visit_item(&mut self, it: &'tcx hir::Item) { fn visit_item(&mut self, it: &'tcx hir::Item) {
let fm = match it.node { let fm = match it.node {
hir::ItemForeignMod(ref fm) => fm, hir::ItemKind::ForeignMod(ref fm) => fm,
_ => return, _ => return,
}; };
if fm.abi == Abi::Rust || if fm.abi == Abi::Rust ||

View File

@ -45,7 +45,7 @@ struct Collector<'a, 'tcx: 'a> {
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> {
fn visit_item(&mut self, it: &'tcx hir::Item) { fn visit_item(&mut self, it: &'tcx hir::Item) {
let fm = match it.node { let fm = match it.node {
hir::ItemForeignMod(ref fm) => fm, hir::ItemKind::ForeignMod(ref fm) => fm,
_ => return, _ => return,
}; };

View File

@ -945,18 +945,18 @@ struct RootCollector<'b, 'a: 'b, 'tcx: 'a + 'b> {
impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
fn visit_item(&mut self, item: &'v hir::Item) { fn visit_item(&mut self, item: &'v hir::Item) {
match item.node { match item.node {
hir::ItemExternCrate(..) | hir::ItemKind::ExternCrate(..) |
hir::ItemUse(..) | hir::ItemKind::Use(..) |
hir::ItemForeignMod(..) | hir::ItemKind::ForeignMod(..) |
hir::ItemTy(..) | hir::ItemKind::Ty(..) |
hir::ItemTrait(..) | hir::ItemKind::Trait(..) |
hir::ItemTraitAlias(..) | hir::ItemKind::TraitAlias(..) |
hir::ItemExistential(..) | hir::ItemKind::Existential(..) |
hir::ItemMod(..) => { hir::ItemKind::Mod(..) => {
// Nothing to do, just keep recursing... // Nothing to do, just keep recursing...
} }
hir::ItemImpl(..) => { hir::ItemKind::Impl(..) => {
if self.mode == MonoItemCollectionMode::Eager { if self.mode == MonoItemCollectionMode::Eager {
create_mono_items_for_default_impls(self.tcx, create_mono_items_for_default_impls(self.tcx,
item, item,
@ -964,9 +964,9 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
} }
} }
hir::ItemEnum(_, ref generics) | hir::ItemKind::Enum(_, ref generics) |
hir::ItemStruct(_, ref generics) | hir::ItemKind::Struct(_, ref generics) |
hir::ItemUnion(_, ref generics) => { hir::ItemKind::Union(_, ref generics) => {
if generics.params.is_empty() { if generics.params.is_empty() {
if self.mode == MonoItemCollectionMode::Eager { if self.mode == MonoItemCollectionMode::Eager {
let def_id = self.tcx.hir.local_def_id(item.id); 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(..) => { hir::ItemKind::GlobalAsm(..) => {
debug!("RootCollector: ItemGlobalAsm({})", debug!("RootCollector: ItemKind::GlobalAsm({})",
def_id_to_string(self.tcx, def_id_to_string(self.tcx,
self.tcx.hir.local_def_id(item.id))); self.tcx.hir.local_def_id(item.id)));
self.output.push(MonoItem::GlobalAsm(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); 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)); def_id_to_string(self.tcx, def_id));
self.output.push(MonoItem::Static(def_id)); self.output.push(MonoItem::Static(def_id));
} }
hir::ItemConst(..) => { hir::ItemKind::Const(..) => {
// const items only generate mono items if they are // const items only generate mono items if they are
// actually used somewhere. Just declaring them is insufficient. // 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)); self.output.push(MonoItem::CustomSection(def_id));
} }
} }
hir::ItemFn(..) => { hir::ItemKind::Fn(..) => {
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir.local_def_id(item.id);
self.push_if_root(def_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, item: &'tcx hir::Item,
output: &mut Vec<MonoItem<'tcx>>) { output: &mut Vec<MonoItem<'tcx>>) {
match item.node { 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 { for param in &generics.params {
match param.kind { match param.kind {
hir::GenericParamKind::Lifetime { .. } => {} hir::GenericParamKind::Lifetime { .. } => {}

View File

@ -405,7 +405,7 @@ fn is_enclosed(tcx: TyCtxt,
if used_unsafe.contains(&parent_id) { if used_unsafe.contains(&parent_id) {
Some(("block".to_string(), parent_id)) Some(("block".to_string(), parent_id))
} else if let Some(hir::map::NodeItem(&hir::Item { } else if let Some(hir::map::NodeItem(&hir::Item {
node: hir::ItemFn(_, header, _, _), node: hir::ItemKind::Fn(_, header, _, _),
.. ..
})) = tcx.hir.find(parent_id) { })) = tcx.hir.find(parent_id) {
match header.unsafety { match header.unsafety {

View File

@ -24,7 +24,7 @@ struct RegistrarFinder {
impl<'v> ItemLikeVisitor<'v> for RegistrarFinder { impl<'v> ItemLikeVisitor<'v> for RegistrarFinder {
fn visit_item(&mut self, item: &hir::Item) { 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, if attr::contains_name(&item.attrs,
"plugin_registrar") { "plugin_registrar") {
self.registrars.push((item.id, item.span)); self.registrars.push((item.id, item.span));

View File

@ -149,21 +149,21 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
fn visit_item(&mut self, item: &'tcx hir::Item) { fn visit_item(&mut self, item: &'tcx hir::Item) {
let inherited_item_level = match item.node { let inherited_item_level = match item.node {
// Impls inherit level from their types and traits // Impls inherit level from their types and traits
hir::ItemImpl(..) => { hir::ItemKind::Impl(..) => {
let def_id = self.tcx.hir.local_def_id(item.id); 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)) cmp::min(self.item_ty_level(def_id), self.impl_trait_level(def_id))
} }
// Foreign mods inherit level from parents // Foreign mods inherit level from parents
hir::ItemForeignMod(..) => { hir::ItemKind::ForeignMod(..) => {
self.prev_level self.prev_level
} }
// Other `pub` items inherit levels from parents // Other `pub` items inherit levels from parents
hir::ItemConst(..) | hir::ItemEnum(..) | hir::ItemExternCrate(..) | hir::ItemKind::Const(..) | hir::ItemKind::Enum(..) | hir::ItemKind::ExternCrate(..) |
hir::ItemGlobalAsm(..) | hir::ItemFn(..) | hir::ItemMod(..) | hir::ItemKind::GlobalAsm(..) | hir::ItemKind::Fn(..) | hir::ItemKind::Mod(..) |
hir::ItemStatic(..) | hir::ItemStruct(..) | hir::ItemKind::Static(..) | hir::ItemKind::Struct(..) |
hir::ItemTrait(..) | hir::ItemTraitAlias(..) | hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..) |
hir::ItemExistential(..) | hir::ItemKind::Existential(..) |
hir::ItemTy(..) | hir::ItemUnion(..) | hir::ItemUse(..) => { hir::ItemKind::Ty(..) | hir::ItemKind::Union(..) | hir::ItemKind::Use(..) => {
if item.vis.node.is_pub() { self.prev_level } else { None } 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 // Update levels of nested things
match item.node { match item.node {
hir::ItemEnum(ref def, _) => { hir::ItemKind::Enum(ref def, _) => {
for variant in &def.variants { for variant in &def.variants {
let variant_level = self.update(variant.node.data.id(), item_level); let variant_level = self.update(variant.node.data.id(), item_level);
for field in variant.node.data.fields() { 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 { for impl_item_ref in impl_item_refs {
if impl_item_ref.vis.node.is_pub() { if impl_item_ref.vis.node.is_pub() {
self.update(impl_item_ref.id.node_id, item_level); 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 { for impl_item_ref in impl_item_refs {
self.update(impl_item_ref.id.node_id, item_level); 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 { for trait_item_ref in trait_item_refs {
self.update(trait_item_ref.id.node_id, item_level); 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() { if !def.is_struct() {
self.update(def.id(), item_level); 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 { for foreign_item in &foreign_mod.items {
if foreign_item.vis.node.is_pub() { if foreign_item.vis.node.is_pub() {
self.update(foreign_item.id, item_level); self.update(foreign_item.id, item_level);
} }
} }
} }
hir::ItemExistential(..) | hir::ItemKind::Existential(..) |
hir::ItemUse(..) | hir::ItemStatic(..) | hir::ItemConst(..) | hir::ItemKind::Use(..) | hir::ItemKind::Static(..) | hir::ItemKind::Const(..) |
hir::ItemGlobalAsm(..) | hir::ItemTy(..) | hir::ItemMod(..) | hir::ItemTraitAlias(..) | hir::ItemKind::GlobalAsm(..) | hir::ItemKind::Ty(..) | hir::ItemKind::Mod(..) | hir::ItemKind::TraitAlias(..) |
hir::ItemFn(..) | hir::ItemExternCrate(..) => {} hir::ItemKind::Fn(..) | hir::ItemKind::ExternCrate(..) => {}
} }
// Mark all items in interfaces of reachable items as reachable // Mark all items in interfaces of reachable items as reachable
match item.node { match item.node {
// The interface is empty // The interface is empty
hir::ItemExternCrate(..) => {} hir::ItemKind::ExternCrate(..) => {}
// All nested items are checked by visit_item // All nested items are checked by visit_item
hir::ItemMod(..) => {} hir::ItemKind::Mod(..) => {}
// Re-exports are handled in visit_mod // Re-exports are handled in visit_mod
hir::ItemUse(..) => {} hir::ItemKind::Use(..) => {}
// The interface is empty // The interface is empty
hir::ItemGlobalAsm(..) => {} hir::ItemKind::GlobalAsm(..) => {}
hir::ItemExistential(..) => { hir::ItemKind::Existential(..) => {
if item_level.is_some() { if item_level.is_some() {
// Reach the (potentially private) type and the API being exposed // Reach the (potentially private) type and the API being exposed
self.reach(item.id).ty().predicates(); self.reach(item.id).ty().predicates();
} }
} }
// Visit everything // Visit everything
hir::ItemConst(..) | hir::ItemStatic(..) | hir::ItemKind::Const(..) | hir::ItemKind::Static(..) |
hir::ItemFn(..) | hir::ItemTy(..) => { hir::ItemKind::Fn(..) | hir::ItemKind::Ty(..) => {
if item_level.is_some() { if item_level.is_some() {
self.reach(item.id).generics().predicates().ty(); 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() { if item_level.is_some() {
self.reach(item.id).generics().predicates(); 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() { if item_level.is_some() {
self.reach(item.id).generics().predicates(); self.reach(item.id).generics().predicates();
} }
} }
// Visit everything except for private impl items // 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() { if item_level.is_some() {
self.reach(item.id).generics().predicates().impl_trait_ref(); 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 // Visit everything, but enum variants have their own levels
hir::ItemEnum(ref def, _) => { hir::ItemKind::Enum(ref def, _) => {
if item_level.is_some() { if item_level.is_some() {
self.reach(item.id).generics().predicates(); 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 // 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 { for foreign_item in &foreign_mod.items {
if self.get(foreign_item.id).is_some() { if self.get(foreign_item.id).is_some() {
self.reach(foreign_item.id).generics().predicates().ty(); 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 // Visit everything except for private fields
hir::ItemStruct(ref struct_def, _) | hir::ItemKind::Struct(ref struct_def, _) |
hir::ItemUnion(ref struct_def, _) => { hir::ItemKind::Union(ref struct_def, _) => {
if item_level.is_some() { if item_level.is_some() {
self.reach(item.id).generics().predicates(); self.reach(item.id).generics().predicates();
for field in struct_def.fields() { for field in struct_def.fields() {
@ -373,7 +373,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
loop { loop {
let module = if module_id == ast::CRATE_NODE_ID { let module = if module_id == ast::CRATE_NODE_ID {
&self.tcx.hir.krate().module &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 module
} else { } else {
unreachable!() unreachable!()
@ -1084,13 +1084,13 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
match item.node { match item.node {
// contents of a private mod can be re-exported, so we need // contents of a private mod can be re-exported, so we need
// to check internals. // to check internals.
hir::ItemMod(_) => {} hir::ItemKind::Mod(_) => {}
// An `extern {}` doesn't introduce a new privacy // An `extern {}` doesn't introduce a new privacy
// namespace (the contents have their own privacies). // 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) { if !self.trait_is_public(item.id) {
return 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 // (i.e. we could just return here to not check them at
// all, or some worse estimation of whether an impl is // all, or some worse estimation of whether an impl is
// publicly visible). // 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. // `impl [... for] Private` is never visible.
let self_contains_private; let self_contains_private;
// impl [... for] Public<...>, but not `impl [... for] // 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 // `type ... = ...;` can contain private types, because
// we're introducing a new name. // we're introducing a new name.
hir::ItemTy(..) => return, hir::ItemKind::Ty(..) => return,
// not at all public, so we don't care // not at all public, so we don't care
_ if !self.item_is_public(&item.id, &item.vis) => { _ 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 { match item.node {
// Crates are always public // Crates are always public
hir::ItemExternCrate(..) => {} hir::ItemKind::ExternCrate(..) => {}
// All nested items are checked by visit_item // All nested items are checked by visit_item
hir::ItemMod(..) => {} hir::ItemKind::Mod(..) => {}
// Checked in resolve // Checked in resolve
hir::ItemUse(..) => {} hir::ItemKind::Use(..) => {}
// No subitems // No subitems
hir::ItemGlobalAsm(..) => {} hir::ItemKind::GlobalAsm(..) => {}
hir::ItemExistential(..) => { hir::ItemKind::Existential(..) => {
// Check the traits being exposed, as they're separate, // Check the traits being exposed, as they're separate,
// e.g. `impl Iterator<Item=T>` has two predicates, // e.g. `impl Iterator<Item=T>` has two predicates,
// `X: Iterator` and `<X as Iterator>::Item == T`, // `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(); self.check(item.id, item_visibility).predicates();
} }
// Subitems of these items have inherited publicity // Subitems of these items have inherited publicity
hir::ItemConst(..) | hir::ItemStatic(..) | hir::ItemFn(..) | hir::ItemKind::Const(..) | hir::ItemKind::Static(..) | hir::ItemKind::Fn(..) |
hir::ItemTy(..) => { hir::ItemKind::Ty(..) => {
self.check(item.id, item_visibility).generics().predicates().ty(); self.check(item.id, item_visibility).generics().predicates().ty();
// Recurse for e.g. `impl Trait` (see `visit_ty`). // Recurse for e.g. `impl Trait` (see `visit_ty`).
self.inner_visibility = item_visibility; self.inner_visibility = item_visibility;
intravisit::walk_item(self, item); 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(); self.check(item.id, item_visibility).generics().predicates();
for trait_item_ref in trait_item_refs { 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(); 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(); self.check(item.id, item_visibility).generics().predicates();
for variant in &def.variants { 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 // 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 { for foreign_item in &foreign_mod.items {
let vis = ty::Visibility::from_hir(&foreign_item.vis, item.id, tcx); let vis = ty::Visibility::from_hir(&foreign_item.vis, item.id, tcx);
self.check(foreign_item.id, vis).generics().predicates().ty(); self.check(foreign_item.id, vis).generics().predicates().ty();
} }
} }
// Subitems of structs and unions have their own publicity // Subitems of structs and unions have their own publicity
hir::ItemStruct(ref struct_def, _) | hir::ItemKind::Struct(ref struct_def, _) |
hir::ItemUnion(ref struct_def, _) => { hir::ItemKind::Union(ref struct_def, _) => {
self.check(item.id, item_visibility).generics().predicates(); self.check(item.id, item_visibility).generics().predicates();
for field in struct_def.fields() { 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 // An inherent impl is public when its type is public
// Subitems of inherent impls have their own publicity // 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 = let ty_vis =
self.check(item.id, ty::Visibility::Invisible).ty().min_visibility; self.check(item.id, ty::Visibility::Invisible).ty().min_visibility;
self.check(item.id, ty_vis).generics().predicates(); 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 // A trait impl is public when both its type and its trait are public
// Subitems of trait impls have inherited publicity // 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) let vis = self.check(item.id, ty::Visibility::Invisible)
.ty().impl_trait_ref().min_visibility; .ty().impl_trait_ref().min_visibility;
self.check(item.id, vis).generics().predicates(); self.check(item.id, vis).generics().predicates();

View File

@ -420,7 +420,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
match self.tcx.impl_of_method(self.tcx.hir.local_def_id(id)) { 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(impl_id) => match self.tcx.hir.get_if_local(impl_id) {
Some(Node::NodeItem(item)) => match item.node { Some(Node::NodeItem(item)) => match item.node {
hir::ItemImpl(.., ref ty, _) => { hir::ItemKind::Impl(.., ref ty, _) => {
let mut qualname = String::from("<"); let mut qualname = String::from("<");
qualname.push_str(&self.tcx.hir.node_to_pretty_string(ty.id)); 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::NodeTraitRef(tr) => tr.path.def,
Node::NodeItem(&hir::Item { Node::NodeItem(&hir::Item {
node: hir::ItemUse(ref path, _), node: hir::ItemKind::Use(ref path, _),
.. ..
}) | }) |
Node::NodeVisibility(&Spanned { Node::NodeVisibility(&Spanned {

View File

@ -18,7 +18,7 @@ use syntax_pos::Span;
use rustc::hir; use rustc::hir;
use rustc::hir::def::Def; use rustc::hir::def::Def;
use rustc::hir::map::{NodeItem, NodeExpr}; 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::{self, Ty, AssociatedItem};
use rustc::ty::adjustment::AllowTwoPhase; use rustc::ty::adjustment::AllowTwoPhase;
use errors::{DiagnosticBuilder, CodeMapper}; use errors::{DiagnosticBuilder, CodeMapper};
@ -376,7 +376,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
match self.tcx.hir.find(parent_id) { match self.tcx.hir.find(parent_id) {
Some(parent) => { Some(parent) => {
// Shouldn't suggest `.into()` on `const`s. // 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 // FIXME(estebank): modify once we decide to suggest `as` casts
return false; return false;
} }

View File

@ -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> { impl<'v, 'a, 'tcx> itemlikevisit::ItemLikeVisitor<'v> for Visitor<'a, 'tcx> {
fn visit_item(&mut self, i: &'v hir::Item) { fn visit_item(&mut self, i: &'v hir::Item) {
match i.node { match i.node {
hir::ItemTrait(..) => { hir::ItemKind::Trait(..) => {
let def_id = self.map.local_def_id(i.id); let def_id = self.map.local_def_id(i.id);
self.traits.push(def_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 { for item_id in &module.item_ids {
let item = self.tcx.hir.expect_item(item_id.id); let item = self.tcx.hir.expect_item(item_id.id);
match item.node { match item.node {
hir::ItemUse(..) => { hir::ItemKind::Use(..) => {
// don't suggest placing a use before the prelude // don't suggest placing a use before the prelude
// import or other generated ones // import or other generated ones
if item.span.ctxt().outer().expn_info().is_none() { 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 // don't place use before extern crate
hir::ItemExternCrate(_) => {} hir::ItemKind::ExternCrate(_) => {}
// but place them before the first other item // but place them before the first other item
_ => if self.span.map_or(true, |span| item.span < span ) { _ => if self.span.map_or(true, |span| item.span < span ) {
if item.span.ctxt().outer().expn_info().is_none() { if item.span.ctxt().outer().expn_info().is_none() {

View File

@ -132,7 +132,7 @@ use syntax_pos::{self, BytePos, Span, MultiSpan};
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap}; use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::hir::map::Node; use rustc::hir::map::Node;
use rustc::hir::{self, PatKind, Item_}; use rustc::hir::{self, PatKind, ItemKind};
use rustc::middle::lang_items; use rustc::middle::lang_items;
mod autoderef; mod autoderef;
@ -759,10 +759,10 @@ fn primary_body_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
match tcx.hir.get(id) { match tcx.hir.get(id) {
hir::map::NodeItem(item) => { hir::map::NodeItem(item) => {
match item.node { match item.node {
hir::ItemConst(_, body) | hir::ItemKind::Const(_, body) |
hir::ItemStatic(_, _, body) => hir::ItemKind::Static(_, _, body) =>
Some((body, None)), Some((body, None)),
hir::ItemFn(ref decl, .., body) => hir::ItemKind::Fn(ref decl, .., body) =>
Some((body, Some(decl))), Some((body, Some(decl))),
_ => _ =>
None, 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 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() { if !generics.params.is_empty() {
fcx.tcx.sess.span_err( fcx.tcx.sess.span_err(
span, 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 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() { if !generics.params.is_empty() {
fcx.tcx.sess.span_err( fcx.tcx.sess.span_err(
span, span,
@ -1269,25 +1269,25 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item
let _indenter = indenter(); let _indenter = indenter();
match it.node { match it.node {
// Consts can play a role in type-checking, so they are included here. // 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)); 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)); tcx.typeck_tables_of(tcx.hir.local_def_id(it.id));
if it.attrs.iter().any(|a| a.check_name("wasm_custom_section")) { if it.attrs.iter().any(|a| a.check_name("wasm_custom_section")) {
let def_id = tcx.hir.local_def_id(it.id); let def_id = tcx.hir.local_def_id(it.id);
check_const_is_u8_array(tcx, def_id, it.span); check_const_is_u8_array(tcx, def_id, it.span);
} }
} }
hir::ItemEnum(ref enum_definition, _) => { hir::ItemKind::Enum(ref enum_definition, _) => {
check_enum(tcx, check_enum(tcx,
it.span, it.span,
&enum_definition.variants, &enum_definition.variants,
it.id); it.id);
} }
hir::ItemFn(..) => {} // entirely within check_item_body hir::ItemKind::Fn(..) => {} // entirely within check_item_body
hir::ItemImpl(.., ref impl_item_refs) => { hir::ItemKind::Impl(.., ref impl_item_refs) => {
debug!("ItemImpl {} with id {}", it.name, it.id); debug!("ItemKind::Impl {} with id {}", it.name, it.id);
let impl_def_id = tcx.hir.local_def_id(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) { if let Some(impl_trait_ref) = tcx.impl_trait_ref(impl_def_id) {
check_impl_items_against_trait(tcx, 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); check_on_unimplemented(tcx, trait_def_id, it);
} }
} }
hir::ItemTrait(..) => { hir::ItemKind::Trait(..) => {
let def_id = tcx.hir.local_def_id(it.id); let def_id = tcx.hir.local_def_id(it.id);
check_on_unimplemented(tcx, def_id, it); check_on_unimplemented(tcx, def_id, it);
} }
hir::ItemStruct(..) => { hir::ItemKind::Struct(..) => {
check_struct(tcx, it.id, it.span); check_struct(tcx, it.id, it.span);
} }
hir::ItemUnion(..) => { hir::ItemKind::Union(..) => {
check_union(tcx, it.id, it.span); check_union(tcx, it.id, it.span);
} }
hir::ItemTy(..) => { hir::ItemKind::Ty(..) => {
let def_id = tcx.hir.local_def_id(it.id); let def_id = tcx.hir.local_def_id(it.id);
let pty_ty = tcx.type_of(def_id); let pty_ty = tcx.type_of(def_id);
let generics = tcx.generics_of(def_id); let generics = tcx.generics_of(def_id);
check_bounds_are_used(tcx, &generics, pty_ty); check_bounds_are_used(tcx, &generics, pty_ty);
} }
hir::ItemForeignMod(ref m) => { hir::ItemKind::ForeignMod(ref m) => {
check_abi(tcx, it.span, m.abi); check_abi(tcx, it.span, m.abi);
if m.abi == Abi::RustIntrinsic { 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); let parent = self.tcx.hir.get(fn_id);
if let Node::NodeItem(&hir::Item { if let Node::NodeItem(&hir::Item {
name, node: hir::ItemFn(ref decl, ..), .. name, node: hir::ItemKind::Fn(ref decl, ..), ..
}) = parent { }) = parent {
decl.clone().and_then(|decl| { decl.clone().and_then(|decl| {
// This is less than ideal, it will not suggest a return type span on any // This is less than ideal, it will not suggest a return type span on any

View File

@ -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` // won't be allowed unless there's an *explicit* implementation of `Send`
// for `T` // 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)) 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)); .map_or(false, |trait_ref| tcx.trait_is_auto(trait_ref.def_id));
if let (hir::Defaultness::Default { .. }, true) = (defaultness, is_auto) { 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); check_item_fn(tcx, item);
} }
hir::ItemStatic(..) => { hir::ItemKind::Static(..) => {
check_item_type(tcx, item); check_item_type(tcx, item);
} }
hir::ItemConst(..) => { hir::ItemKind::Const(..) => {
check_item_type(tcx, item); 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| { check_type_defn(tcx, item, false, |fcx| {
vec![fcx.non_enum_variant(struct_def)] vec![fcx.non_enum_variant(struct_def)]
}); });
check_variances_for_type_defn(tcx, item, ast_generics); 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| { check_type_defn(tcx, item, true, |fcx| {
vec![fcx.non_enum_variant(struct_def)] vec![fcx.non_enum_variant(struct_def)]
}); });
check_variances_for_type_defn(tcx, item, ast_generics); 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| { check_type_defn(tcx, item, true, |fcx| {
fcx.enum_variants(enum_def) fcx.enum_variants(enum_def)
}); });
check_variances_for_type_defn(tcx, item, ast_generics); check_variances_for_type_defn(tcx, item, ast_generics);
} }
hir::ItemTrait(..) => { hir::ItemKind::Trait(..) => {
check_trait(tcx, item); check_trait(tcx, item);
} }
_ => {} _ => {}

View File

@ -42,7 +42,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CheckVisitor<'a, 'tcx> {
if item.vis.node.is_pub() || item.span.is_dummy() { if item.vis.node.is_pub() || item.span.is_dummy() {
return; 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); self.check_import(item.id, path.span);
} }
} }
@ -196,7 +196,7 @@ struct ExternCrateToLint {
impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CollectExternCrateVisitor<'a, 'tcx> { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CollectExternCrateVisitor<'a, 'tcx> {
fn visit_item(&mut self, item: &hir::Item) { 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); let extern_crate_def_id = self.tcx.hir.local_def_id(item.id);
self.crates_to_lint.push( self.crates_to_lint.push(
ExternCrateToLint { ExternCrateToLint {

View File

@ -24,7 +24,7 @@ use rustc::infer;
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::hir::map as hir_map; 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) { pub fn check_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_def_id: DefId) {
Checker { tcx, trait_def_id } 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) { match tcx.hir.find(impl_node_id) {
Some(hir_map::NodeItem(item)) => { Some(hir_map::NodeItem(item)) => {
let span = match item.node { let span = match item.node {
ItemImpl(.., ref ty, _) => ty.span, ItemKind::Impl(.., ref ty, _) => ty.span,
_ => item.span, _ => item.span,
}; };
struct_span_err!(tcx.sess, struct_span_err!(tcx.sess,
@ -115,7 +115,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
Ok(()) => {} Ok(()) => {}
Err(CopyImplementationError::InfrigingFields(fields)) => { Err(CopyImplementationError::InfrigingFields(fields)) => {
let item = tcx.hir.expect_item(impl_node_id); 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 tr.path.span
} else { } else {
span span
@ -132,7 +132,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
} }
Err(CopyImplementationError::NotAnAdt) => { Err(CopyImplementationError::NotAnAdt) => {
let item = tcx.hir.expect_item(impl_node_id); 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 ty.span
} else { } else {
span span
@ -336,7 +336,7 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>,
return err_info; return err_info;
} else if diff_fields.len() > 1 { } else if diff_fields.len() > 1 {
let item = gcx.hir.expect_item(impl_node_id); 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 t.path.span
} else { } else {
gcx.hir.span(impl_node_id) gcx.hir.span(impl_node_id)

View File

@ -94,7 +94,7 @@ struct InherentCollect<'a, 'tcx: 'a> {
impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
fn visit_item(&mut self, item: &hir::Item) { fn visit_item(&mut self, item: &hir::Item) {
let ty = match item.node { let ty = match item.node {
hir::ItemImpl(.., None, ref ty, _) => ty, hir::ItemKind::Impl(.., None, ref ty, _) => ty,
_ => return _ => return
}; };

View File

@ -122,10 +122,10 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {
impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentOverlapChecker<'a, 'tcx> { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentOverlapChecker<'a, 'tcx> {
fn visit_item(&mut self, item: &'v hir::Item) { fn visit_item(&mut self, item: &'v hir::Item) {
match item.node { match item.node {
hir::ItemEnum(..) | hir::ItemKind::Enum(..) |
hir::ItemStruct(..) | hir::ItemKind::Struct(..) |
hir::ItemTrait(..) | hir::ItemKind::Trait(..) |
hir::ItemUnion(..) => { hir::ItemKind::Union(..) => {
let type_def_id = self.tcx.hir.local_def_id(item.id); let type_def_id = self.tcx.hir.local_def_id(item.id);
self.check_for_overlapping_inherent_impls(type_def_id); self.check_for_overlapping_inherent_impls(type_def_id);
} }

View File

@ -34,7 +34,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> {
fn visit_item(&mut self, item: &hir::Item) { fn visit_item(&mut self, item: &hir::Item) {
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir.local_def_id(item.id);
match item.node { match item.node {
hir::ItemImpl(.., Some(_), _, _) => { hir::ItemKind::Impl(.., Some(_), _, _) => {
// "Trait" impl // "Trait" impl
debug!("coherence2::orphan check: trait impl {}", debug!("coherence2::orphan check: trait impl {}",
self.tcx.hir.node_to_string(item.id)); self.tcx.hir.node_to_string(item.id));

View File

@ -84,7 +84,7 @@ impl<'cx, 'tcx, 'v> UnsafetyChecker<'cx, 'tcx> {
impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for UnsafetyChecker<'cx, 'tcx> { impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for UnsafetyChecker<'cx, 'tcx> {
fn visit_item(&mut self, item: &'v hir::Item) { fn visit_item(&mut self, item: &'v hir::Item) {
match item.node { 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); self.check_unsafety_coherence(item, Some(generics), unsafety, polarity);
} }
_ => {} _ => {}

View File

@ -266,13 +266,13 @@ fn type_param_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
NodeItem(item) => { NodeItem(item) => {
match item.node { match item.node {
ItemFn(.., ref generics, _) | ItemKind::Fn(.., ref generics, _) |
ItemImpl(_, _, _, ref generics, ..) | ItemKind::Impl(_, _, _, ref generics, ..) |
ItemTy(_, ref generics) | ItemKind::Ty(_, ref generics) |
ItemEnum(_, ref generics) | ItemKind::Enum(_, ref generics) |
ItemStruct(_, ref generics) | ItemKind::Struct(_, ref generics) |
ItemUnion(_, ref generics) => generics, ItemKind::Union(_, ref generics) => generics,
ItemTrait(_, _, ref generics, ..) => { ItemKind::Trait(_, _, ref generics, ..) => {
// Implied `Self: Trait` and supertrait bounds. // Implied `Self: Trait` and supertrait bounds.
if param_id == item_node_id { if param_id == item_node_id {
result.predicates.push( 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); let def_id = tcx.hir.local_def_id(item_id);
match it.node { match it.node {
// These don't define types. // These don't define types.
hir::ItemExternCrate(_) | hir::ItemKind::ExternCrate(_) |
hir::ItemUse(..) | hir::ItemKind::Use(..) |
hir::ItemMod(_) | hir::ItemKind::Mod(_) |
hir::ItemGlobalAsm(_) => {} hir::ItemKind::GlobalAsm(_) => {}
hir::ItemForeignMod(ref foreign_mod) => { hir::ItemKind::ForeignMod(ref foreign_mod) => {
for item in &foreign_mod.items { for item in &foreign_mod.items {
let def_id = tcx.hir.local_def_id(item.id); let def_id = tcx.hir.local_def_id(item.id);
tcx.generics_of(def_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.generics_of(def_id);
tcx.type_of(def_id); tcx.type_of(def_id);
tcx.predicates_of(def_id); tcx.predicates_of(def_id);
convert_enum_variant_types(tcx, def_id, &enum_definition.variants); convert_enum_variant_types(tcx, def_id, &enum_definition.variants);
}, },
hir::ItemImpl(..) => { hir::ItemKind::Impl(..) => {
tcx.generics_of(def_id); tcx.generics_of(def_id);
tcx.type_of(def_id); tcx.type_of(def_id);
tcx.impl_trait_ref(def_id); tcx.impl_trait_ref(def_id);
tcx.predicates_of(def_id); tcx.predicates_of(def_id);
}, },
hir::ItemTrait(..) => { hir::ItemKind::Trait(..) => {
tcx.generics_of(def_id); tcx.generics_of(def_id);
tcx.trait_def(def_id); tcx.trait_def(def_id);
tcx.at(it.span).super_predicates_of(def_id); tcx.at(it.span).super_predicates_of(def_id);
tcx.predicates_of(def_id); tcx.predicates_of(def_id);
}, },
hir::ItemTraitAlias(..) => { hir::ItemKind::TraitAlias(..) => {
span_err!(tcx.sess, it.span, E0645, span_err!(tcx.sess, it.span, E0645,
"trait aliases are not yet implemented (see issue #41517)"); "trait aliases are not yet implemented (see issue #41517)");
}, },
hir::ItemStruct(ref struct_def, _) | hir::ItemKind::Struct(ref struct_def, _) |
hir::ItemUnion(ref struct_def, _) => { hir::ItemKind::Union(ref struct_def, _) => {
tcx.generics_of(def_id); tcx.generics_of(def_id);
tcx.type_of(def_id); tcx.type_of(def_id);
tcx.predicates_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()); convert_variant_ctor(tcx, struct_def.id());
} }
}, },
hir::ItemExistential(..) => {} hir::ItemKind::Existential(..) => {}
hir::ItemTy(..) | hir::ItemStatic(..) | hir::ItemConst(..) | hir::ItemFn(..) => { hir::ItemKind::Ty(..) | hir::ItemKind::Static(..) | hir::ItemKind::Const(..) | hir::ItemKind::Fn(..) => {
tcx.generics_of(def_id); tcx.generics_of(def_id);
tcx.type_of(def_id); tcx.type_of(def_id);
tcx.predicates_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); 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 repr = ReprOptions::new(tcx, def_id);
let (kind, variants) = match item.node { let (kind, variants) = match item.node {
ItemEnum(ref def, _) => { ItemKind::Enum(ref def, _) => {
let mut distance_from_explicit = 0; let mut distance_from_explicit = 0;
(AdtKind::Enum, def.variants.iter().map(|v| { (AdtKind::Enum, def.variants.iter().map(|v| {
let did = tcx.hir.local_def_id(v.node.data.id()); 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) convert_struct_variant(tcx, did, v.node.name, discr, &v.node.data)
}).collect()) }).collect())
} }
ItemStruct(ref def, _) => { ItemKind::Struct(ref def, _) => {
// Use separate constructor id for unit/tuple structs and reuse did for braced structs. // Use separate constructor id for unit/tuple structs and reuse did for braced structs.
let ctor_id = if !def.is_struct() { let ctor_id = if !def.is_struct() {
Some(tcx.hir.local_def_id(def.id())) 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) ty::VariantDiscr::Relative(0), def)
]) ])
} }
ItemUnion(ref def, _) => { ItemKind::Union(ref def, _) => {
(AdtKind::Union, vec![ (AdtKind::Union, vec![
convert_struct_variant(tcx, def_id, item.name, convert_struct_variant(tcx, def_id, item.name,
ty::VariantDiscr::Relative(0), def) 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 { let (generics, bounds) = match item.node {
hir::ItemTrait(.., ref generics, ref supertraits, _) => (generics, supertraits), hir::ItemKind::Trait(.., ref generics, ref supertraits, _) => (generics, supertraits),
hir::ItemTraitAlias(ref generics, ref supertraits) => (generics, supertraits), hir::ItemKind::TraitAlias(ref generics, ref supertraits) => (generics, supertraits),
_ => span_bug!(item.span, _ => span_bug!(item.span,
"super_predicates invoked on non-trait"), "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 item = tcx.hir.expect_item(node_id);
let (is_auto, unsafety) = match item.node { let (is_auto, unsafety) = match item.node {
hir::ItemTrait(is_auto, unsafety, ..) => (is_auto == hir::IsAuto::Yes, unsafety), hir::ItemKind::Trait(is_auto, unsafety, ..) => (is_auto == hir::IsAuto::Yes, unsafety),
hir::ItemTraitAlias(..) => (false, hir::Unsafety::Normal), hir::ItemKind::TraitAlias(..) => (false, hir::Unsafety::Normal),
_ => span_bug!(item.span, "trait_def_of_item invoked on non-trait"), _ => 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, _ => None,
}, },
hir_map::NodeItem(item) => match item.node { 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), has_late_bound_regions(tcx, generics, fn_decl),
_ => None, _ => None,
}, },
@ -810,7 +810,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
} }
NodeItem(item) => { NodeItem(item) => {
match item.node { match item.node {
ItemExistential(hir::ExistTy { impl_trait_fn, .. }) => impl_trait_fn, ItemKind::Existential(hir::ExistTy { impl_trait_fn, .. }) => impl_trait_fn,
_ => None, _ => None,
} }
}, },
@ -828,19 +828,19 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
NodeItem(item) => { NodeItem(item) => {
match item.node { match item.node {
ItemFn(.., ref generics, _) | ItemKind::Fn(.., ref generics, _) |
ItemImpl(_, _, _, ref generics, ..) => generics, ItemKind::Impl(_, _, _, ref generics, ..) => generics,
ItemTy(_, ref generics) | ItemKind::Ty(_, ref generics) |
ItemEnum(_, ref generics) | ItemKind::Enum(_, ref generics) |
ItemStruct(_, ref generics) | ItemKind::Struct(_, ref generics) |
ItemExistential(hir::ExistTy { ref generics, .. }) | ItemKind::Existential(hir::ExistTy { ref generics, .. }) |
ItemUnion(_, ref generics) => { ItemKind::Union(_, ref generics) => {
allow_defaults = true; allow_defaults = true;
generics generics
} }
ItemTrait(_, _, ref generics, ..) | ItemTraitAlias(ref generics, ..) => { ItemKind::Trait(_, _, ref generics, ..) | ItemKind::TraitAlias(ref generics, ..) => {
// Add in the self type parameter. // Add in the self type parameter.
// //
// Something of a hack: use the node id for the trait, also as // 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) => { NodeItem(item) => {
match item.node { match item.node {
ItemStatic(ref t, ..) | ItemConst(ref t, _) | ItemKind::Static(ref t, ..) | ItemKind::Const(ref t, _) |
ItemTy(ref t, _) | ItemImpl(.., ref t, _) => { ItemKind::Ty(ref t, _) | ItemKind::Impl(.., ref t, _) => {
icx.to_ty(t) icx.to_ty(t)
} }
ItemFn(..) => { ItemKind::Fn(..) => {
let substs = Substs::identity_for_item(tcx, def_id); let substs = Substs::identity_for_item(tcx, def_id);
tcx.mk_fn_def(def_id, substs) tcx.mk_fn_def(def_id, substs)
} }
ItemEnum(..) | ItemKind::Enum(..) |
ItemStruct(..) | ItemKind::Struct(..) |
ItemUnion(..) => { ItemKind::Union(..) => {
let def = tcx.adt_def(def_id); let def = tcx.adt_def(def_id);
let substs = Substs::identity_for_item(tcx, def_id); let substs = Substs::identity_for_item(tcx, def_id);
tcx.mk_adt(def, substs) tcx.mk_adt(def, substs)
} }
// this is only reachable once we have named existential types // 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 // 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] tcx.typeck_tables_of(owner).concrete_existential_types[&def_id]
}, },
ItemTrait(..) | ItemTraitAlias(..) | ItemKind::Trait(..) | ItemKind::TraitAlias(..) |
ItemMod(..) | ItemKind::Mod(..) |
ItemForeignMod(..) | ItemKind::ForeignMod(..) |
ItemGlobalAsm(..) | ItemKind::GlobalAsm(..) |
ItemExternCrate(..) | ItemKind::ExternCrate(..) |
ItemUse(..) => { ItemKind::Use(..) => {
span_bug!( span_bug!(
item.span, item.span,
"compute_type_of_item: unexpected item type: {:?}", "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) 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) 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(); let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
match tcx.hir.expect_item(node_id).node { 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| { opt_trait_ref.as_ref().map(|ast_trait_ref| {
let selfty = tcx.type_of(def_id); let selfty = tcx.type_of(def_id);
AstConv::instantiate_mono_trait_ref(&icx, ast_trait_ref, selfty) 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 { -> hir::ImplPolarity {
let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
match tcx.hir.expect_item(node_id).node { 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) ref item => bug!("impl_polarity: {:?} not an impl", item)
} }
} }
@ -1371,23 +1371,23 @@ fn explicit_predicates_of<'a, 'tcx>(
NodeItem(item) => { NodeItem(item) => {
match item.node { match item.node {
ItemImpl(_, _, defaultness, ref generics, ..) => { ItemKind::Impl(_, _, defaultness, ref generics, ..) => {
if defaultness.is_default() { if defaultness.is_default() {
is_default_impl_trait = tcx.impl_trait_ref(def_id); is_default_impl_trait = tcx.impl_trait_ref(def_id);
} }
generics generics
} }
ItemFn(.., ref generics, _) | ItemKind::Fn(.., ref generics, _) |
ItemTy(_, ref generics) | ItemKind::Ty(_, ref generics) |
ItemEnum(_, ref generics) | ItemKind::Enum(_, ref generics) |
ItemStruct(_, ref generics) | ItemKind::Struct(_, ref generics) |
ItemUnion(_, ref generics) => 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)); is_trait = Some((ty::TraitRef::identity(tcx, def_id), items));
generics generics
} }
ItemExistential(ref exist_ty) => { ItemKind::Existential(ref exist_ty) => {
let substs = Substs::identity_for_item(tcx, def_id); let substs = Substs::identity_for_item(tcx, def_id);
let anon_ty = tcx.mk_anon(def_id, substs); 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 // before uses of `U`. This avoids false ambiguity errors
// in trait checking. See `setup_constraining_predicates` // in trait checking. See `setup_constraining_predicates`
// for details. // 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 self_ty = tcx.type_of(def_id);
let trait_ref = tcx.impl_trait_ref(def_id); let trait_ref = tcx.impl_trait_ref(def_id);
ctp::setup_constraining_predicates(tcx, ctp::setup_constraining_predicates(tcx,

View File

@ -72,7 +72,7 @@ struct ImplWfCheck<'a, 'tcx: 'a> {
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for ImplWfCheck<'a, 'tcx> { impl<'a, 'tcx> ItemLikeVisitor<'tcx> for ImplWfCheck<'a, 'tcx> {
fn visit_item(&mut self, item: &'tcx hir::Item) { fn visit_item(&mut self, item: &'tcx hir::Item) {
match item.node { 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); let impl_def_id = self.tcx.hir.local_def_id(item.id);
enforce_impl_params_are_constrained(self.tcx, enforce_impl_params_are_constrained(self.tcx,
impl_def_id, impl_def_id,

View File

@ -189,7 +189,7 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
match tcx.hir.find(main_id) { match tcx.hir.find(main_id) {
Some(hir_map::NodeItem(it)) => { Some(hir_map::NodeItem(it)) => {
match it.node { match it.node {
hir::ItemFn(.., ref generics, _) => { hir::ItemKind::Fn(.., ref generics, _) => {
let mut error = false; let mut error = false;
if !generics.params.is_empty() { if !generics.params.is_empty() {
let msg = format!("`main` function is not allowed to have generic \ 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) { match tcx.hir.find(start_id) {
Some(hir_map::NodeItem(it)) => { Some(hir_map::NodeItem(it)) => {
match it.node { match it.node {
hir::ItemFn(.., ref generics, _) => { hir::ItemKind::Fn(.., ref generics, _) => {
let mut error = false; let mut error = false;
if !generics.params.is_empty() { if !generics.params.is_empty() {
struct_span_err!(tcx.sess, generics.span, E0132, struct_span_err!(tcx.sess, generics.span, E0132,

View File

@ -77,7 +77,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> {
let mut item_required_predicates = RequiredPredicates::default(); let mut item_required_predicates = RequiredPredicates::default();
match item.node { 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); let adt_def = self.tcx.adt_def(item_did);
// Iterate over all fields in item_did // Iterate over all fields in item_did

View File

@ -41,7 +41,7 @@ fn inferred_outlives_of<'a, 'tcx>(
match tcx.hir.get(id) { match tcx.hir.get(id) {
hir_map::NodeItem(item) => match item.node { 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 crate_map = tcx.inferred_outlives_crate(LOCAL_CRATE);
let predicates = crate_map let predicates = crate_map

View File

@ -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> { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> {
fn visit_item(&mut self, item: &hir::Item) { fn visit_item(&mut self, item: &hir::Item) {
match item.node { match item.node {
hir::ItemStruct(ref struct_def, _) | hir::ItemKind::Struct(ref struct_def, _) |
hir::ItemUnion(ref struct_def, _) => { hir::ItemKind::Union(ref struct_def, _) => {
self.visit_node_helper(item.id); self.visit_node_helper(item.id);
if let hir::VariantData::Tuple(..) = *struct_def { 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); self.visit_node_helper(item.id);
for variant in &enum_def.variants { 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); self.visit_node_helper(item.id);
} }
hir::ItemForeignMod(ref foreign_mod) => { hir::ItemKind::ForeignMod(ref foreign_mod) => {
for foreign_item in &foreign_mod.items { for foreign_item in &foreign_mod.items {
if let hir::ForeignItemKind::Fn(..) = foreign_item.node { if let hir::ForeignItemKind::Fn(..) = foreign_item.node {
self.visit_node_helper(foreign_item.id); self.visit_node_helper(foreign_item.id);

View File

@ -62,10 +62,10 @@ fn variances_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId)
}; };
match tcx.hir.get(id) { match tcx.hir.get(id) {
hir::map::NodeItem(item) => match item.node { hir::map::NodeItem(item) => match item.node {
hir::ItemEnum(..) | hir::ItemKind::Enum(..) |
hir::ItemStruct(..) | hir::ItemKind::Struct(..) |
hir::ItemUnion(..) | hir::ItemKind::Union(..) |
hir::ItemFn(..) => {} hir::ItemKind::Fn(..) => {}
_ => unsupported() _ => unsupported()
}, },

View File

@ -142,8 +142,8 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> {
self.tcx.hir.node_to_string(item.id)); self.tcx.hir.node_to_string(item.id));
match item.node { match item.node {
hir::ItemStruct(ref struct_def, _) | hir::ItemKind::Struct(ref struct_def, _) |
hir::ItemUnion(ref struct_def, _) => { hir::ItemKind::Union(ref struct_def, _) => {
self.add_inferreds_for_item(item.id); self.add_inferreds_for_item(item.id);
if let hir::VariantData::Tuple(..) = *struct_def { 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); self.add_inferreds_for_item(item.id);
for variant in &enum_def.variants { 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); 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 { for foreign_item in &foreign_mod.items {
if let hir::ForeignItemKind::Fn(..) = foreign_item.node { if let hir::ForeignItemKind::Fn(..) = foreign_item.node {
self.add_inferreds_for_item(foreign_item.id); self.add_inferreds_for_item(foreign_item.id);

View File

@ -10,6 +10,7 @@
use rustc::traits::auto_trait as auto; use rustc::traits::auto_trait as auto;
use rustc::ty::TypeFoldable; use rustc::ty::TypeFoldable;
use rustc::hir;
use std::fmt::Debug; use std::fmt::Debug;
use super::*; 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 did = self.cx.tcx.hir.local_def_id(id);
let def_ctor = match *item { let def_ctor = match *item {
hir::ItemStruct(_, _) => Def::Struct, hir::ItemKind::Struct(_, _) => Def::Struct,
hir::ItemUnion(_, _) => Def::Union, hir::ItemKind::Union(_, _) => Def::Union,
hir::ItemEnum(_, _) => Def::Enum, hir::ItemKind::Enum(_, _) => Def::Enum,
_ => panic!("Unexpected type {:?} {:?}", item, id), _ => panic!("Unexpected type {:?} {:?}", item, id),
}; };
@ -216,7 +217,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
let ty = hir::Ty { let ty = hir::Ty {
id: ast::DUMMY_NODE_ID, 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, span: DUMMY_SP,
hir_id: hir::DUMMY_HIR_ID, 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); debug!("ty_param_to_ty({:?}) {:?}", param, param.def_id);
hir::Ty { hir::Ty {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node: hir::TyKind::TyPath(hir::QPath::Resolved( node: hir::TyKind::Path(hir::QPath::Resolved(
None, None,
P(hir::Path { P(hir::Path {
span: DUMMY_SP, span: DUMMY_SP,

View File

@ -283,10 +283,10 @@ impl Clean<ExternalCrate> for CrateNum {
cx.tcx.hir.krate().module.item_ids.iter().filter_map(|&id| { cx.tcx.hir.krate().module.item_ids.iter().filter_map(|&id| {
let item = cx.tcx.hir.expect_item(id.id); let item = cx.tcx.hir.expect_item(id.id);
match item.node { match item.node {
hir::ItemMod(_) => { hir::ItemKind::Mod(_) => {
as_primitive(Def::Mod(cx.tcx.hir.local_def_id(id.id))) 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() => { if item.vis.node.is_pub() => {
as_primitive(path.def).map(|(_, prim, attrs)| { as_primitive(path.def).map(|(_, prim, attrs)| {
// Pretend the primitive is local. // 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| { cx.tcx.hir.krate().module.item_ids.iter().filter_map(|&id| {
let item = cx.tcx.hir.expect_item(id.id); let item = cx.tcx.hir.expect_item(id.id);
match item.node { match item.node {
hir::ItemMod(_) => { hir::ItemKind::Mod(_) => {
as_keyword(Def::Mod(cx.tcx.hir.local_def_id(id.id))) 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() => { if item.vis.node.is_pub() => {
as_keyword(path.def).map(|(_, prim, attrs)| { as_keyword(path.def).map(|(_, prim, attrs)| {
(cx.tcx.hir.local_def_id(id.id), 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 { fn clean(&self, cx: &DocContext) -> Type {
use rustc::hir::*; use rustc::hir::*;
match self.node { match self.node {
TyNever => Never, TyKind::Never => Never,
TyPtr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)), TyKind::Ptr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)),
TyRptr(ref l, ref m) => { TyKind::Rptr(ref l, ref m) => {
let lifetime = if l.is_elided() { let lifetime = if l.is_elided() {
None None
} else { } else {
@ -2863,8 +2863,8 @@ impl Clean<Type> for hir::Ty {
BorrowedRef {lifetime: lifetime, mutability: m.mutbl.clean(cx), BorrowedRef {lifetime: lifetime, mutability: m.mutbl.clean(cx),
type_: box m.ty.clean(cx)} type_: box m.ty.clean(cx)}
} }
TySlice(ref ty) => Slice(box ty.clean(cx)), TyKind::Slice(ref ty) => Slice(box ty.clean(cx)),
TyArray(ref ty, ref length) => { TyKind::Array(ref ty, ref length) => {
let def_id = cx.tcx.hir.local_def_id(length.id); let def_id = cx.tcx.hir.local_def_id(length.id);
let param_env = cx.tcx.param_env(def_id); let param_env = cx.tcx.param_env(def_id);
let substs = Substs::identity_for_item(cx.tcx, 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); let length = print_const(cx, length);
Array(box ty.clean(cx), length) Array(box ty.clean(cx), length)
}, },
TyTup(ref tys) => Tuple(tys.clean(cx)), TyKind::Tup(ref tys) => Tuple(tys.clean(cx)),
TyPath(hir::QPath::Resolved(None, ref path)) => { TyKind::Path(hir::QPath::Resolved(None, ref path)) => {
if let Some(new_ty) = cx.ty_substs.borrow().get(&path.def).cloned() { if let Some(new_ty) = cx.ty_substs.borrow().get(&path.def).cloned() {
return new_ty; 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 provided_params = &path.segments.last().unwrap();
let mut ty_substs = FxHashMap(); let mut ty_substs = FxHashMap();
let mut lt_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) 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(); let mut segments: Vec<_> = p.segments.clone().into();
segments.pop(); segments.pop();
let trait_path = hir::Path { 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) 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 mut def = Def::Err;
let ty = hir_ty_to_ty(cx.tcx, self); let ty = hir_ty_to_ty(cx.tcx, self);
if let ty::TyProjection(proj) = ty.sty { 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) 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_ { match bounds[0].clean(cx).trait_ {
ResolvedPath { path, typarams: None, did, is_generic } => { ResolvedPath { path, typarams: None, did, is_generic } => {
let mut bounds: Vec<self::GenericBound> = bounds[1..].iter().map(|bound| { 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 _ => Infer // shouldn't happen
} }
} }
TyBareFn(ref barefn) => BareFunction(box barefn.clean(cx)), TyKind::BareFn(ref barefn) => BareFunction(box barefn.clean(cx)),
TyInfer | TyErr => Infer, TyKind::Infer | TyKind::Err => Infer,
TyTypeof(..) => panic!("Unimplemented type {:?}", self.node), 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 { 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") _ => panic!("Unexpected item {:?} in path {:?} path")
}; };
break; break;

View File

@ -706,7 +706,7 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirCollector<'a, 'hir> {
} }
fn visit_item(&mut self, item: &'hir hir::Item) { 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) self.map.node_to_pretty_string(ty.id)
} else { } else {
item.name.to_string() item.name.to_string()

View File

@ -297,7 +297,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
if !self.view_item_stack.insert(def_node_id) { return false } if !self.view_item_stack.insert(def_node_id) { return false }
let ret = match tcx.hir.get(def_node_id) { 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); let prev = mem::replace(&mut self.inlining, true);
for i in &m.item_ids { for i in &m.item_ids {
let i = self.cx.tcx.hir.expect_item(i.id); 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 { match item.node {
hir::ItemForeignMod(ref fm) => { hir::ItemKind::ForeignMod(ref fm) => {
// If inlining we only want to include public functions. // If inlining we only want to include public functions.
om.foreigns.push(if self.inlining { om.foreigns.push(if self.inlining {
hir::ForeignMod { hir::ForeignMod {
@ -353,8 +353,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
} }
// If we're inlining, skip private items. // If we're inlining, skip private items.
_ if self.inlining && !item.vis.node.is_pub() => {} _ if self.inlining && !item.vis.node.is_pub() => {}
hir::ItemGlobalAsm(..) => {} hir::ItemKind::GlobalAsm(..) => {}
hir::ItemExternCrate(orig_name) => { hir::ItemKind::ExternCrate(orig_name) => {
let def_id = self.cx.tcx.hir.local_def_id(item.id); let def_id = self.cx.tcx.hir.local_def_id(item.id);
om.extern_crates.push(ExternCrate { om.extern_crates.push(ExternCrate {
cnum: self.cx.tcx.extern_mod_stmt_cnum(def_id) 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, whence: item.span,
}) })
} }
hir::ItemUse(_, hir::UseKind::ListStem) => {} hir::ItemKind::Use(_, hir::UseKind::ListStem) => {}
hir::ItemUse(ref path, kind) => { hir::ItemKind::Use(ref path, kind) => {
let is_glob = kind == hir::UseKind::Glob; let is_glob = kind == hir::UseKind::Glob;
// struct and variant constructors always show up alongside their definitions, we've // 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, whence: item.span,
}); });
} }
hir::ItemMod(ref m) => { hir::ItemKind::Mod(ref m) => {
om.mods.push(self.visit_mod_contents(item.span, om.mods.push(self.visit_mod_contents(item.span,
item.attrs.clone(), item.attrs.clone(),
item.vis.clone(), item.vis.clone(),
@ -417,15 +417,15 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
m, m,
Some(name))); 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)), 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)), 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)), 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)), 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 { let t = Typedef {
ty: ty.clone(), ty: ty.clone(),
gen: gen.clone(), gen: gen.clone(),
@ -439,7 +439,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
}; };
om.typedefs.push(t); om.typedefs.push(t);
}, },
hir::ItemStatic(ref ty, ref mut_, ref exp) => { hir::ItemKind::Static(ref ty, ref mut_, ref exp) => {
let s = Static { let s = Static {
type_: ty.clone(), type_: ty.clone(),
mutability: mut_.clone(), mutability: mut_.clone(),
@ -454,7 +454,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
}; };
om.statics.push(s); om.statics.push(s);
}, },
hir::ItemConst(ref ty, ref exp) => { hir::ItemKind::Const(ref ty, ref exp) => {
let s = Constant { let s = Constant {
type_: ty.clone(), type_: ty.clone(),
expr: exp.clone(), expr: exp.clone(),
@ -468,7 +468,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
}; };
om.constants.push(s); 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() let items = item_ids.iter()
.map(|ti| self.cx.tcx.hir.trait_item(ti.id).clone()) .map(|ti| self.cx.tcx.hir.trait_item(ti.id).clone())
.collect(); .collect();
@ -488,11 +488,11 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
}; };
om.traits.push(t); om.traits.push(t);
}, },
hir::ItemTraitAlias(..) => { hir::ItemKind::TraitAlias(..) => {
unimplemented!("trait objects are not yet implemented") unimplemented!("trait objects are not yet implemented")
}, },
hir::ItemImpl(unsafety, hir::ItemKind::Impl(unsafety,
polarity, polarity,
defaultness, defaultness,
ref gen, ref gen,
@ -523,7 +523,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
om.impls.push(i); om.impls.push(i);
} }
}, },
hir::ItemExistential(_) => { hir::ItemKind::Existential(_) => {
// FIXME(oli-obk): actually generate docs for real existential items // FIXME(oli-obk): actually generate docs for real existential items
} }
} }