From: varkor Date: Thu, 26 Sep 2019 16:51:36 +0000 (+0100) Subject: Rename `Item.node` to `Item.kind` X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=7bc94cc3c2ccef8b4d393910bb978a6487db1202;hp=21bf983acbb5d7ac8fb9462cbf2cc4c280abd857;p=rust.git Rename `Item.node` to `Item.kind` --- diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 8340c17b4b7..c946118b1ea 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -65,7 +65,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { impl Target { pub(crate) fn from_item(item: &hir::Item) -> Target { - match item.node { + match item.kind { hir::ItemKind::ExternCrate(..) => Target::ExternCrate, hir::ItemKind::Use(..) => Target::Use, hir::ItemKind::Static(..) => Target::Static, @@ -333,7 +333,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) { } fn is_c_like_enum(item: &hir::Item) -> bool { - if let hir::ItemKind::Enum(ref def, _) = item.node { + if let hir::ItemKind::Enum(ref def, _) = item.kind { for variant in &def.variants { match variant.data { hir::VariantData::Unit(..) => { /* continue */ } diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 188f3c53729..3f6c7f22f16 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -465,7 +465,7 @@ pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param) { pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { visitor.visit_vis(&item.vis); visitor.visit_ident(item.ident); - match item.node { + match item.kind { ItemKind::ExternCrate(orig_name) => { visitor.visit_id(item.hir_id); if let Some(orig_name) = orig_name { diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 24ea32b65ea..d0a9d967a64 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -437,7 +437,7 @@ fn visit_pat(&mut self, p: &'tcx Pat) { fn visit_item(&mut self, item: &'tcx Item) { let hir_id = self.lctx.allocate_hir_id_counter(item.id); - match item.node { + match item.kind { ItemKind::Struct(_, ref generics) | ItemKind::Union(_, ref generics) | ItemKind::Enum(_, ref generics) @@ -1445,7 +1445,7 @@ fn generate_opaque_type( hir_id: opaque_ty_id, ident: Ident::invalid(), attrs: Default::default(), - node: opaque_ty_item_kind, + kind: opaque_ty_item_kind, vis: respan(span.shrink_to_lo(), hir::VisibilityKind::Inherited), span: opaque_ty_span, }; diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index 14311585652..ab477d6e1c1 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -73,7 +73,7 @@ fn visit_item(&mut self, item: &'tcx Item) { if let Some(hir_id) = item_hir_id { self.lctx.with_parent_item_lifetime_defs(hir_id, |this| { let this = &mut ItemLowerer { lctx: this }; - if let ItemKind::Impl(.., ref opt_trait_ref, _, _) = item.node { + if let ItemKind::Impl(.., ref opt_trait_ref, _, _) = item.kind { this.with_trait_impl_ref(opt_trait_ref, |this| { visit::walk_item(this, item) }); @@ -119,7 +119,7 @@ fn with_parent_item_lifetime_defs( ) -> T { let old_len = self.in_scope_lifetimes.len(); - let parent_generics = match self.items.get(&parent_hir_id).unwrap().node { + let parent_generics = match self.items.get(&parent_hir_id).unwrap().kind { hir::ItemKind::Impl(_, _, _, ref generics, ..) | hir::ItemKind::Trait(_, _, ref generics, ..) => { &generics.params[..] @@ -168,7 +168,7 @@ pub(super) fn lower_mod(&mut self, m: &Mod) -> hir::Mod { } pub(super) fn lower_item_id(&mut self, i: &Item) -> SmallVec<[hir::ItemId; 1]> { - let node_ids = match i.node { + let node_ids = match i.kind { ItemKind::Use(ref use_tree) => { let mut vec = smallvec![i.id]; self.lower_item_id_use_tree(use_tree, i.id, &mut vec); @@ -235,7 +235,7 @@ pub fn lower_item(&mut self, i: &Item) -> Option { } let attrs = attrs.into(); - if let ItemKind::MacroDef(ref def) = i.node { + if let ItemKind::MacroDef(ref def) = i.kind { if !def.legacy || attr::contains_name(&i.attrs, sym::macro_export) { let body = self.lower_token_stream(def.stream()); let hir_id = self.lower_node_id(i.id); @@ -254,13 +254,13 @@ pub fn lower_item(&mut self, i: &Item) -> Option { return None; } - let node = self.lower_item_kind(i.id, &mut ident, &attrs, &mut vis, &i.node); + let kind = self.lower_item_kind(i.id, &mut ident, &attrs, &mut vis, &i.kind); Some(hir::Item { hir_id: self.lower_node_id(i.id), ident, attrs, - node, + kind, vis, span: i.span, }) @@ -542,7 +542,7 @@ fn lower_use_tree( let res = this.lower_res(res); let path = this.lower_path_extra(res, &path, ParamMode::Explicit, None); - let item = hir::ItemKind::Use(P(path), hir::UseKind::Single); + let kind = hir::ItemKind::Use(P(path), hir::UseKind::Single); let vis = this.rebuild_vis(&vis); this.insert_item( @@ -550,7 +550,7 @@ fn lower_use_tree( hir_id: new_id, ident, attrs: attrs.into_iter().cloned().collect(), - node: item, + kind, vis, span, }, @@ -558,8 +558,7 @@ fn lower_use_tree( }); } - let path = - P(self.lower_path_extra(ret_res, &path, ParamMode::Explicit, None)); + let path = P(self.lower_path_extra(ret_res, &path, ParamMode::Explicit, None)); hir::ItemKind::Use(path, hir::UseKind::Single) } UseTreeKind::Glob => { @@ -623,7 +622,7 @@ fn lower_use_tree( let mut vis = this.rebuild_vis(&vis); let mut ident = *ident; - let item = this.lower_use_tree(use_tree, + let kind = this.lower_use_tree(use_tree, &prefix, id, &mut vis, @@ -635,7 +634,7 @@ fn lower_use_tree( hir_id: new_hir_id, ident, attrs: attrs.into_iter().cloned().collect(), - node: item, + kind, vis, span: use_tree.span, }, diff --git a/src/librustc/hir/map/blocks.rs b/src/librustc/hir/map/blocks.rs index a6da2e92df1..f670d5abe85 100644 --- a/src/librustc/hir/map/blocks.rs +++ b/src/librustc/hir/map/blocks.rs @@ -37,7 +37,10 @@ pub struct FnLikeNode<'a> { node: Node<'a> } impl MaybeFnLike for ast::Item { fn is_fn_like(&self) -> bool { - match self.node { ast::ItemKind::Fn(..) => true, _ => false, } + match self.kind { + ast::ItemKind::Fn(..) => true, + _ => false, + } } } @@ -215,7 +218,7 @@ fn handle(self, item_fn: I, method: M, closure: C) -> A where C: FnOnce(ClosureParts<'a>) -> A, { match self.node { - map::Node::Item(i) => match i.node { + map::Node::Item(i) => match i.kind { ast::ItemKind::Fn(ref decl, header, ref generics, block) => item_fn(ItemFnParts { id: i.hir_id, diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 815a239405c..c69d682b6f7 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -378,7 +378,7 @@ fn visit_item(&mut self, i: &'hir Item) { self.with_dep_node_owner(i.hir_id.owner, i, |this| { this.insert(i.span, i.hir_id, Node::Item(i)); this.with_parent(i.hir_id, |this| { - if let ItemKind::Struct(ref struct_def, _) = i.node { + if let ItemKind::Struct(ref struct_def, _) = i.kind { // If this is a tuple or unit-like struct, register the constructor. if let Some(ctor_hir_id) = struct_def.ctor_hir_id() { this.insert(i.span, ctor_hir_id, Node::Ctor(struct_def)); diff --git a/src/librustc/hir/map/def_collector.rs b/src/librustc/hir/map/def_collector.rs index 74137f81bf8..4235da76f53 100644 --- a/src/librustc/hir/map/def_collector.rs +++ b/src/librustc/hir/map/def_collector.rs @@ -101,7 +101,7 @@ fn visit_item(&mut self, i: &'a Item) { // Pick the def data. This need not be unique, but the more // information we encapsulate into, the better - let def_data = match i.node { + let def_data = match i.kind { ItemKind::Impl(..) => DefPathData::Impl, ItemKind::Mod(..) if i.ident.name == kw::Invalid => { return visit::walk_item(self, i); @@ -138,7 +138,7 @@ fn visit_item(&mut self, i: &'a Item) { let def = self.create_def(i.id, def_data, i.span); self.with_parent(def, |this| { - match i.node { + match i.kind { ItemKind::Struct(ref struct_def, _) | ItemKind::Union(ref struct_def, _) => { // If this is a unit or tuple-like struct, register the constructor. if let Some(ctor_hir_id) = struct_def.ctor_id() { diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 2d319a64d4d..c13bb3cb1f2 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -50,7 +50,7 @@ fn parent_node(self) -> Option { fn fn_decl(&self) -> Option<&'hir FnDecl> { match self.node { Node::Item(ref item) => { - match item.node { + match item.kind { ItemKind::Fn(ref fn_decl, _, _, _) => Some(fn_decl), _ => None, } @@ -84,7 +84,7 @@ fn fn_decl(&self) -> Option<&'hir FnDecl> { fn associated_body(self) -> Option { match self.node { Node::Item(item) => { - match item.node { + match item.kind { ItemKind::Const(_, body) | ItemKind::Static(.., body) | ItemKind::Fn(_, _, _, body) => Some(body), @@ -293,7 +293,7 @@ pub fn def_kind(&self, hir_id: HirId) -> Option { Some(match node { Node::Item(item) => { - match item.node { + match item.kind { ItemKind::Static(..) => DefKind::Static, ItemKind::Const(..) => DefKind::Const, ItemKind::Fn(..) => DefKind::Fn, @@ -453,19 +453,19 @@ pub fn body_owned_by(&self, id: HirId) -> BodyId { pub fn body_owner_kind(&self, id: HirId) -> BodyOwnerKind { match self.get(id) { - Node::Item(&Item { node: ItemKind::Const(..), .. }) | + Node::Item(&Item { kind: ItemKind::Const(..), .. }) | Node::TraitItem(&TraitItem { kind: TraitItemKind::Const(..), .. }) | Node::ImplItem(&ImplItem { kind: ImplItemKind::Const(..), .. }) | Node::AnonConst(_) => { BodyOwnerKind::Const } Node::Ctor(..) | - Node::Item(&Item { node: ItemKind::Fn(..), .. }) | + Node::Item(&Item { kind: ItemKind::Fn(..), .. }) | Node::TraitItem(&TraitItem { kind: TraitItemKind::Method(..), .. }) | Node::ImplItem(&ImplItem { kind: ImplItemKind::Method(..), .. }) => { BodyOwnerKind::Fn } - Node::Item(&Item { node: ItemKind::Static(_, m, _), .. }) => { + Node::Item(&Item { kind: ItemKind::Static(_, m, _), .. }) => { BodyOwnerKind::Static(m) } Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => { @@ -477,8 +477,8 @@ pub fn body_owner_kind(&self, id: HirId) -> BodyOwnerKind { pub fn ty_param_owner(&self, id: HirId) -> HirId { match self.get(id) { - Node::Item(&Item { node: ItemKind::Trait(..), .. }) | - Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => id, + Node::Item(&Item { kind: ItemKind::Trait(..), .. }) | + Node::Item(&Item { kind: ItemKind::TraitAlias(..), .. }) => id, Node::GenericParam(_) => self.get_parent_node(id), _ => bug!("ty_param_owner: {} not a type parameter", self.node_to_string(id)) } @@ -486,8 +486,8 @@ pub fn ty_param_owner(&self, id: HirId) -> HirId { pub fn ty_param_name(&self, id: HirId) -> Name { match self.get(id) { - Node::Item(&Item { node: ItemKind::Trait(..), .. }) | - Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => kw::SelfUpper, + Node::Item(&Item { kind: ItemKind::Trait(..), .. }) | + Node::Item(&Item { kind: ItemKind::TraitAlias(..), .. }) => kw::SelfUpper, Node::GenericParam(param) => param.name.ident().name, _ => bug!("ty_param_name: {} not a type parameter", self.node_to_string(id)), } @@ -517,7 +517,7 @@ pub fn get_module(&self, module: DefId) -> (&'hir Mod, Span, HirId) { match self.find_entry(hir_id).unwrap().node { Node::Item(&Item { span, - node: ItemKind::Mod(ref m), + kind: ItemKind::Mod(ref m), .. }) => (m, span, hir_id), Node::Crate => (&self.forest.krate.module, self.forest.krate.span, hir_id), @@ -568,7 +568,7 @@ pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics> { Node::ImplItem(ref impl_item) => Some(&impl_item.generics), Node::TraitItem(ref trait_item) => Some(&trait_item.generics), Node::Item(ref item) => { - match item.node { + match item.kind { ItemKind::Fn(_, _, ref generics, _) | ItemKind::TyAlias(_, ref generics) | ItemKind::Enum(_, ref generics) | @@ -649,7 +649,7 @@ pub fn is_const_context(&self, hir_id: HirId) -> bool { let parent_id = self.get_parent_item(hir_id); match self.get(parent_id) { Node::Item(&Item { - node: ItemKind::Const(..), + kind: ItemKind::Const(..), .. }) | Node::TraitItem(&TraitItem { @@ -662,11 +662,11 @@ pub fn is_const_context(&self, hir_id: HirId) -> bool { }) | Node::AnonConst(_) | Node::Item(&Item { - node: ItemKind::Static(..), + kind: ItemKind::Static(..), .. }) => true, Node::Item(&Item { - node: ItemKind::Fn(_, header, ..), + kind: ItemKind::Fn(_, header, ..), .. }) => header.constness == Constness::Const, _ => false, @@ -676,7 +676,7 @@ pub fn is_const_context(&self, hir_id: HirId) -> bool { /// Wether `hir_id` corresponds to a `mod` or a crate. pub fn is_hir_id_module(&self, hir_id: HirId) -> bool { match self.lookup(hir_id) { - Some(Entry { node: Node::Item(Item { node: ItemKind::Mod(_), .. }), .. }) | + Some(Entry { node: Node::Item(Item { kind: ItemKind::Mod(_), .. }), .. }) | Some(Entry { node: Node::Crate, .. }) => true, _ => false, } @@ -796,7 +796,7 @@ pub fn get_module_parent(&self, id: HirId) -> DefId { /// module parent is in this map. pub fn get_module_parent_node(&self, hir_id: HirId) -> HirId { match self.walk_parent_nodes(hir_id, |node| match *node { - Node::Item(&Item { node: ItemKind::Mod(_), .. }) => true, + Node::Item(&Item { kind: ItemKind::Mod(_), .. }) => true, _ => false, }, |_| false) { Ok(id) => id, @@ -808,7 +808,7 @@ pub fn get_module_parent_node(&self, hir_id: HirId) -> HirId { pub fn get_enclosing_scope(&self, hir_id: HirId) -> Option { self.walk_parent_nodes(hir_id, |node| match *node { Node::Item(i) => { - match i.node { + match i.kind { ItemKind::Fn(..) | ItemKind::Mod(..) | ItemKind::Enum(..) @@ -852,7 +852,7 @@ pub fn get_defining_scope(&self, id: HirId) -> Option { } match self.get(scope) { Node::Item(i) => { - match i.node { + match i.kind { ItemKind::OpaqueTy(OpaqueTy { impl_trait_fn: None, .. }) => {} _ => break, } @@ -872,7 +872,7 @@ pub fn get_foreign_abi(&self, hir_id: HirId) -> Abi { let parent = self.get_parent_item(hir_id); if let Some(entry) = self.find_entry(parent) { if let Entry { - node: Node::Item(Item { node: ItemKind::ForeignMod(ref nm), .. }), .. } = entry + node: Node::Item(Item { kind: ItemKind::ForeignMod(ref nm), .. }), .. } = entry { self.read(hir_id); // reveals some of the content of a node return nm.abi; @@ -905,7 +905,7 @@ pub fn expect_trait_item(&self, id: HirId) -> &'hir TraitItem { pub fn expect_variant_data(&self, id: HirId) -> &'hir VariantData { match self.find(id) { Some(Node::Item(i)) => { - match i.node { + match i.kind { ItemKind::Struct(ref struct_def, _) | ItemKind::Union(ref struct_def, _) => struct_def, _ => bug!("struct ID bound to non-struct {}", self.node_to_string(id)) @@ -1123,7 +1123,7 @@ fn find_first_mod_parent(map: &Map<'_>, mut id: HirId) -> Option<(HirId, Name)> } fn item_is_mod(item: &Item) -> bool { - match item.node { + match item.kind { ItemKind::Mod(_) => true, _ => false, } @@ -1286,7 +1286,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String { match map.find(id) { Some(Node::Item(item)) => { - let item_str = match item.node { + let item_str = match item.kind { ItemKind::ExternCrate(..) => "extern crate", ItemKind::Use(..) => "use", ItemKind::Static(..) => "static", diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index e5cc045d38c..abb4a88d04c 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -2416,7 +2416,7 @@ pub struct Item { pub ident: Ident, pub hir_id: HirId, pub attrs: HirVec, - pub node: ItemKind, + pub kind: ItemKind, pub vis: Visibility, pub span: Span, } diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 2c2884e1020..de9a458c06f 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -474,7 +474,7 @@ pub fn print_item(&mut self, item: &hir::Item) { self.maybe_print_comment(item.span.lo()); self.print_outer_attributes(&item.attrs); self.ann.pre(self, AnnNode::Item(item)); - match item.node { + match item.kind { hir::ItemKind::ExternCrate(orig_name) => { self.head(visibility_qualified(&item.vis, "extern crate")); if let Some(orig_name) = orig_name { diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index c92a9e97d22..8e74f1e11eb 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -312,7 +312,7 @@ fn hash_stable(&self, ident, ref attrs, hir_id: _, - ref node, + ref kind, ref vis, span } = *self; @@ -320,7 +320,7 @@ fn hash_stable(&self, hcx.hash_hir_item_like(|hcx| { ident.name.hash_stable(hcx, hasher); attrs.hash_stable(hcx, hasher); - node.hash_stable(hcx, hasher); + kind.hash_stable(hcx, hasher); vis.hash_stable(hcx, hasher); span.hash_stable(hcx, hasher); }); diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 58164fbe146..d31b527a55b 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -248,7 +248,7 @@ fn emit_msg_span( } fn item_scope_tag(item: &hir::Item) -> &'static str { - match item.node { + match item.kind { hir::ItemKind::Impl(..) => "impl", hir::ItemKind::Struct(..) => "struct", hir::ItemKind::Union(..) => "union", diff --git a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs index 42017a23581..9c362a5e207 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -31,7 +31,7 @@ pub(super) fn find_anon_type( if let Some(hir_id) = self.tcx().hir().as_local_hir_id(def_id) { let fndecl = match self.tcx().hir().get(hir_id) { Node::Item(&hir::Item { - node: hir::ItemKind::Fn(ref fndecl, ..), + kind: hir::ItemKind::Fn(ref fndecl, ..), .. }) => &fndecl, Node::TraitItem(&hir::TraitItem { diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index 02b641a8519..3b3649fd811 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -1036,7 +1036,7 @@ fn instantiate_opaque_types_in_map>(&mut self, value: &T) .local_def_id(opaque_parent_hir_id) }; let (in_definition_scope, origin) = match tcx.hir().find(opaque_hir_id) { - Some(Node::Item(item)) => match item.node { + Some(Node::Item(item)) => match item.kind { // Anonymous `impl Trait` hir::ItemKind::OpaqueTy(hir::OpaqueTy { impl_trait_fn: Some(parent), diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 3483efbd840..fa73a3c6c46 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -981,7 +981,7 @@ fn visit_body(&mut self, body: &'tcx hir::Body) { fn visit_item(&mut self, it: &'tcx hir::Item) { let generics = self.context.generics.take(); - self.context.generics = it.node.generics(); + self.context.generics = it.kind.generics(); self.with_lint_attrs(it.hir_id, &it.attrs, |cx| { cx.with_param_env(it.hir_id, |cx| { lint_callback!(cx, check_item, it); diff --git a/src/librustc/lint/internal.rs b/src/librustc/lint/internal.rs index f0271db54f6..a08722e9402 100644 --- a/src/librustc/lint/internal.rs +++ b/src/librustc/lint/internal.rs @@ -218,7 +218,7 @@ fn gen_args(segment: &PathSegment) -> String { impl EarlyLintPass for LintPassImpl { fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { - if let ItemKind::Impl(_, _, _, _, Some(lint_pass), _, _) = &item.node { + if let ItemKind::Impl(_, _, _, _, Some(lint_pass), _, _) = &item.kind { if let Some(last) = lint_pass.path.segments.last() { if last.ident.name == sym::LintPass { let expn_data = lint_pass.path.span.ctxt().outer_expn_data(); diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 7d0b7e8e7e8..845f214106b 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -166,7 +166,7 @@ fn visit_node(&mut self, node: Node<'tcx>) { self.inherited_pub_visibility = false; match node { Node::Item(item) => { - match item.node { + match item.kind { hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => { let def_id = self.tcx.hir().local_def_id(item.hir_id); let def = self.tcx.adt_def(def_id); @@ -369,7 +369,7 @@ fn visit_item(&mut self, item: &hir::Item) { if allow_dead_code { self.worklist.push(item.hir_id); } - match item.node { + match item.kind { hir::ItemKind::Enum(ref enum_def, _) => { if allow_dead_code { self.worklist.extend(enum_def.variants.iter().map(|variant| variant.id)); @@ -482,7 +482,7 @@ struct DeadVisitor<'tcx> { impl DeadVisitor<'tcx> { fn should_warn_about_item(&mut self, item: &hir::Item) -> bool { - let should_warn = match item.node { + let should_warn = match item.kind { hir::ItemKind::Static(..) | hir::ItemKind::Const(..) | hir::ItemKind::Fn(..) @@ -571,7 +571,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) { if self.should_warn_about_item(item) { // For items that have a definition with a signature followed by a // block, point only at the signature. - let span = match item.node { + let span = match item.kind { hir::ItemKind::Fn(..) | hir::ItemKind::Mod(..) | hir::ItemKind::Enum(..) | @@ -581,7 +581,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) { hir::ItemKind::Impl(..) => self.tcx.sess.source_map().def_span(item.span), _ => item.span, }; - let participle = match item.node { + let participle = match item.kind { hir::ItemKind::Struct(..) => "constructed", // Issue #52325 _ => "used" }; @@ -589,7 +589,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) { item.hir_id, span, item.ident.name, - item.node.descriptive_variant(), + item.kind.descriptive_variant(), participle, ); } else { diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index ba27d332e43..660fe14ba07 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -80,7 +80,7 @@ fn entry_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<(DefId, EntryFnType)> { // Beware, this is duplicated in `libsyntax/entry.rs`, so make sure to keep // them in sync. fn entry_point_type(item: &Item, at_root: bool) -> EntryPointType { - match item.node { + match item.kind { ItemKind::Fn(..) => { if attr::contains_name(&item.attrs, sym::start) { EntryPointType::Start diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 061a1f62918..8be64bf64b5 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -32,7 +32,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item, attrs: CodegenFnAt return true } - match item.node { + match item.kind { hir::ItemKind::Fn(_, header, ..) if header.is_const() => { return true; } @@ -157,7 +157,7 @@ fn def_id_represents_local_inlined_item(&self, def_id: DefId) -> bool { match self.tcx.hir().find(hir_id) { Some(Node::Item(item)) => { - match item.node { + match item.kind { hir::ItemKind::Fn(..) => item_might_be_inlined(self.tcx, &item, self.tcx.codegen_fn_attrs(def_id)), _ => false, @@ -187,7 +187,7 @@ fn def_id_represents_local_inlined_item(&self, def_id: DefId) -> bool { // type of the impl require inlining, this method // does too. let impl_hir_id = self.tcx.hir().as_local_hir_id(impl_did).unwrap(); - match self.tcx.hir().expect_item(impl_hir_id).node { + match self.tcx.hir().expect_item(impl_hir_id).kind { hir::ItemKind::Impl(..) => { let generics = self.tcx.generics_of(impl_did); generics.requires_monomorphization(self.tcx) @@ -225,7 +225,7 @@ fn propagate_node(&mut self, node: &Node<'tcx>, // If we are building an executable, only explicitly extern // types need to be exported. if let Node::Item(item) = *node { - let reachable = if let hir::ItemKind::Fn(_, header, ..) = item.node { + let reachable = if let hir::ItemKind::Fn(_, header, ..) = item.kind { header.abi != Abi::Rust } else { false @@ -249,7 +249,7 @@ fn propagate_node(&mut self, node: &Node<'tcx>, match *node { Node::Item(item) => { - match item.node { + match item.kind { hir::ItemKind::Fn(.., body) => { let def_id = self.tcx.hir().local_def_id(item.hir_id); if item_might_be_inlined(self.tcx, @@ -361,7 +361,7 @@ fn visit_item(&mut self, item: &hir::Item) { } // We need only trait impls here, not inherent impls, and only non-exported ones - if let hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.node { + if let hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.kind { if !self.access_levels.is_reachable(item.hir_id) { self.worklist.extend(impl_item_refs.iter().map(|ii_ref| ii_ref.id.hir_id)); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 875d0d7dd02..8340df4fecf 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -459,7 +459,7 @@ fn visit_nested_body(&mut self, body: hir::BodyId) { } fn visit_item(&mut self, item: &'tcx hir::Item) { - match item.node { + match item.kind { hir::ItemKind::Fn(ref decl, _, ref generics, _) => { self.visit_early_late(None, decl, generics, |this| { intravisit::walk_item(this, item); @@ -504,12 +504,12 @@ fn visit_item(&mut self, item: &'tcx hir::Item) { | hir::ItemKind::Impl(_, _, _, ref generics, ..) => { // Impls permit `'_` to be used and it is equivalent to "some fresh lifetime name". // This is not true for other kinds of items.x - let track_lifetime_uses = match item.node { + let track_lifetime_uses = match item.kind { hir::ItemKind::Impl(..) => true, _ => false, }; // These kinds of items have only early-bound lifetime parameters. - let mut index = if sub_items_have_self_param(&item.node) { + let mut index = if sub_items_have_self_param(&item.kind) { 1 // Self comes before lifetimes } else { 0 @@ -637,8 +637,7 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty) { // `type MyAnonTy<'b> = impl MyTrait<'b>;` // ^ ^ this gets resolved in the scope of // the opaque_ty generics - let (generics, bounds) = match self.tcx.hir().expect_item(item_id.id).node - { + let (generics, bounds) = match self.tcx.hir().expect_item(item_id.id).kind { // Named opaque `impl Trait` types are reached via `TyKind::Path`. // This arm is for `impl Trait` in the types of statics, constants and locals. hir::ItemKind::OpaqueTy(hir::OpaqueTy { @@ -1263,7 +1262,7 @@ fn check_if_label_shadows_lifetime( fn compute_object_lifetime_defaults(tcx: TyCtxt<'_>) -> HirIdMap> { let mut map = HirIdMap::default(); for item in tcx.hir().krate().items.values() { - match item.node { + match item.kind { hir::ItemKind::Struct(_, ref generics) | hir::ItemKind::Union(_, ref generics) | hir::ItemKind::Enum(_, ref generics) @@ -1525,7 +1524,7 @@ fn suggest_eliding_single_use_lifetime( { match parent { Node::Item(item) => { - if let hir::ItemKind::Fn(decl, _, _, _) = &item.node { + if let hir::ItemKind::Fn(decl, _, _, _) = &item.kind { find_arg_use_span(&decl.inputs); } }, @@ -1733,10 +1732,10 @@ fn visit_early_late( let mut index = 0; if let Some(parent_id) = parent_id { let parent = self.tcx.hir().expect_item(parent_id); - if sub_items_have_self_param(&parent.node) { + if sub_items_have_self_param(&parent.kind) { index += 1; // Self comes before lifetimes } - match parent.node { + match parent.kind { hir::ItemKind::Trait(_, _, ref generics, ..) | hir::ItemKind::Impl(_, _, _, ref generics, ..) => { index += generics.params.len() as u32; @@ -1867,7 +1866,7 @@ fn resolve_lifetime_ref(&mut self, lifetime_ref: &'tcx hir::Lifetime) { let fn_id = self.tcx.hir().body_owner(body_id); match self.tcx.hir().get(fn_id) { Node::Item(&hir::Item { - node: hir::ItemKind::Fn(..), + kind: hir::ItemKind::Fn(..), .. }) | Node::TraitItem(&hir::TraitItem { @@ -2165,7 +2164,7 @@ fn visit_fn_like_elision(&mut self, inputs: &'tcx [hir::Ty], output: Option<&'tc let body = match self.tcx.hir().get(parent) { // `fn` definitions and methods. Node::Item(&hir::Item { - node: hir::ItemKind::Fn(.., body), + kind: hir::ItemKind::Fn(.., body), .. }) => Some(body), @@ -2176,7 +2175,7 @@ fn visit_fn_like_elision(&mut self, inputs: &'tcx [hir::Ty], output: Option<&'tc if let hir::ItemKind::Trait(.., ref trait_items) = self.tcx .hir() .expect_item(self.tcx.hir().get_parent_item(parent)) - .node + .kind { assoc_item_kind = trait_items .iter() @@ -2196,7 +2195,7 @@ fn visit_fn_like_elision(&mut self, inputs: &'tcx [hir::Ty], output: Option<&'tc if let hir::ItemKind::Impl(.., ref self_ty, ref impl_items) = self.tcx .hir() .expect_item(self.tcx.hir().get_parent_item(parent)) - .node + .kind { impl_self = Some(self_ty); assoc_item_kind = impl_items diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index c06a0feb6a9..0e4bab6eaf2 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -246,7 +246,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn visit_item(&mut self, i: &'tcx Item) { let orig_in_trait_impl = self.in_trait_impl; let mut kind = AnnotationKind::Required; - match i.node { + match i.kind { // Inherent impls and foreign modules serve only as containers for other items, // 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 @@ -344,14 +344,14 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { } fn visit_item(&mut self, i: &'tcx Item) { - match i.node { + match i.kind { // Inherent impls and foreign modules serve only as containers for other items, // they don't have their own stability. They still can be annotated as unstable // and propagate this unstability to children, but this annotation is completely // optional. They inherit stability from their parents when unannotated. hir::ItemKind::Impl(.., None, _, _) | hir::ItemKind::ForeignMod(..) => {} - _ => self.check_missing_stability(i.hir_id, i.span, i.node.descriptive_variant()) + _ => self.check_missing_stability(i.hir_id, i.span, i.kind.descriptive_variant()) } intravisit::walk_item(self, i) @@ -797,7 +797,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { } fn visit_item(&mut self, item: &'tcx hir::Item) { - match item.node { + match item.kind { hir::ItemKind::ExternCrate(_) => { // compiler-generated `extern crate` items have a dummy span. if item.span.is_dummy() { return } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 13601c6fe16..1ce5d72ba84 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -1001,7 +1001,7 @@ fn suggest_fn_call( Ok(EvaluationResult::EvaluatedToAmbig) => { if let Some(hir::Node::Item(hir::Item { ident, - node: hir::ItemKind::Fn(.., body_id), + kind: hir::ItemKind::Fn(.., body_id), .. })) = self.tcx.hir().get_if_local(def_id) { let body = self.tcx.hir().body(*body_id); @@ -1106,7 +1106,7 @@ fn suggest_semicolon_removal( let parent_node = hir.get_parent_node(obligation.cause.body_id); let node = hir.find(parent_node); if let Some(hir::Node::Item(hir::Item { - node: hir::ItemKind::Fn(decl, _, _, body_id), + kind: hir::ItemKind::Fn(decl, _, _, body_id), .. })) = node { let body = hir.body(*body_id); @@ -1163,7 +1163,7 @@ pub fn get_fn_like_arguments(&self, node: Node<'_>) -> (Span, Vec) { } Node::Item(&hir::Item { span, - node: hir::ItemKind::Fn(ref decl, ..), + kind: hir::ItemKind::Fn(ref decl, ..), .. }) | Node::ImplItem(&hir::ImplItem { diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index 6a99d12d1a4..6d0347563d0 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -654,7 +654,7 @@ pub fn impl_is_default(self, node_item_def_id: DefId) -> bool { match self.hir().as_local_hir_id(node_item_def_id) { Some(hir_id) => { let item = self.hir().expect_item(hir_id); - if let hir::ItemKind::Impl(_, _, defaultness, ..) = item.node { + if let hir::ItemKind::Impl(_, _, defaultness, ..) = item.kind { defaultness.is_default() } else { false diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 972eae45d18..daf871463b2 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1554,7 +1554,7 @@ pub fn return_type_impl_trait( let hir_id = self.hir().as_local_hir_id(scope_def_id).unwrap(); match self.hir().get(hir_id) { Node::Item(item) => { - match item.node { + match item.kind { ItemKind::Fn(..) => { /* `type_of_def_id()` will work */ } _ => { return None; diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index bd5ac5e5ab4..f107af0cd07 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -3164,7 +3164,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> AssocItem { let parent_id = tcx.hir().get_parent_item(id); let parent_def_id = tcx.hir().local_def_id(parent_id); let parent_item = tcx.hir().expect_item(parent_id); - match parent_item.node { + match parent_item.kind { hir::ItemKind::Impl(.., ref impl_item_refs) => { if let Some(impl_item_ref) = impl_item_refs.iter().find(|i| i.id.hir_id == id) { let assoc_item = tcx.associated_item_from_impl_item_ref(parent_def_id, @@ -3189,7 +3189,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> AssocItem { span_bug!(parent_item.span, "unexpected parent of trait or impl item or item not found: {:?}", - parent_item.node) + parent_item.kind) } #[derive(Clone, HashStable)] @@ -3221,7 +3221,7 @@ fn adt_sized_constraint(tcx: TyCtxt<'_>, def_id: DefId) -> AdtSizedConstraint<'_ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] { let id = tcx.hir().as_local_hir_id(def_id).unwrap(); let item = tcx.hir().expect_item(id); - match item.node { + match item.kind { hir::ItemKind::Trait(.., ref trait_item_refs) => { tcx.arena.alloc_from_iter( trait_item_refs.iter() @@ -3262,7 +3262,7 @@ fn trait_of_item(tcx: TyCtxt<'_>, def_id: DefId) -> Option { pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option { if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) { if let Node::Item(item) = tcx.hir().get(hir_id) { - if let hir::ItemKind::OpaqueTy(ref opaque_ty) = item.node { + if let hir::ItemKind::OpaqueTy(ref opaque_ty) = item.kind { return opaque_ty.impl_trait_fn; } } diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index 4fd971ca115..ccecacd6205 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -230,7 +230,7 @@ impl CodegenCx<'ll, 'tcx> { let llty = self.layout_of(ty).llvm_type(self); let (g, attrs) = match self.tcx.hir().get(id) { Node::Item(&hir::Item { - ref attrs, span, node: hir::ItemKind::Static(..), .. + ref attrs, span, kind: hir::ItemKind::Static(..), .. }) => { let sym_str = sym.as_str(); if self.get_declared_value(&sym_str).is_some() { diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs index b6ae999a8e9..d634b73430a 100644 --- a/src/librustc_codegen_ssa/back/symbol_export.rs +++ b/src/librustc_codegen_ssa/back/symbol_export.rs @@ -94,11 +94,11 @@ fn reachable_non_generics_provider( // Only consider nodes that actually have exported symbols. Node::Item(&hir::Item { - node: hir::ItemKind::Static(..), + kind: hir::ItemKind::Static(..), .. }) | Node::Item(&hir::Item { - node: hir::ItemKind::Fn(..), .. + kind: hir::ItemKind::Fn(..), .. }) | Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Method(..), @@ -367,7 +367,7 @@ fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel // Emscripten cannot export statics, so reduce their export level here if tcx.sess.target.target.options.is_like_emscripten { if let Some(Node::Item(&hir::Item { - node: hir::ItemKind::Static(..), + kind: hir::ItemKind::Static(..), .. })) = tcx.hir().get_if_local(sym_def_id) { return SymbolExportLevel::Rust; diff --git a/src/librustc_codegen_ssa/mono_item.rs b/src/librustc_codegen_ssa/mono_item.rs index 5801963c101..10177d2997a 100644 --- a/src/librustc_codegen_ssa/mono_item.rs +++ b/src/librustc_codegen_ssa/mono_item.rs @@ -30,7 +30,7 @@ fn define>(&self, cx: &'a Bx::CodegenCx) { } MonoItem::GlobalAsm(hir_id) => { let item = cx.tcx().hir().expect_item(hir_id); - if let hir::ItemKind::GlobalAsm(ref ga) = item.node { + if let hir::ItemKind::GlobalAsm(ref ga) = item.kind { cx.codegen_global_asm(ga); } else { span_bug!(item.span, "Mismatch between hir::Item type and MonoItem type") diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index a907a89162e..abe0ffb0e02 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -327,7 +327,7 @@ fn auto_labels(&mut self, item_id: hir::HirId, attr: &Attribute) -> (&'static st let node = self.tcx.hir().get(item_id); let (name, labels) = match node { HirNode::Item(item) => { - match item.node { + match item.kind { // note: these are in the same order as hir::Item_; // FIXME(michaelwoerister): do commented out ones @@ -391,7 +391,7 @@ fn auto_labels(&mut self, item_id: hir::HirId, attr: &Attribute) -> (&'static st &format!( "clean/dirty auto-assertions not yet defined \ for Node::Item.node={:?}", - item.node + item.kind ) ), } diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 1cb909d24ef..d0a7eab071c 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -117,7 +117,7 @@ fn check_heap_type(&self, cx: &LateContext<'_, '_>, span: Span, ty: Ty<'_>) { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers { fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { - match it.node { + match it.kind { hir::ItemKind::Fn(..) | hir::ItemKind::TyAlias(..) | hir::ItemKind::Enum(..) | @@ -130,7 +130,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { } // If it's a struct, we also have to check the fields' types - match it.node { + match it.kind { hir::ItemKind::Struct(ref struct_def, _) | hir::ItemKind::Union(ref struct_def, _) => { for struct_field in struct_def.fields() { @@ -233,7 +233,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) { } fn check_item(&mut self, cx: &EarlyContext<'_>, it: &ast::Item) { - match it.node { + match it.kind { ast::ItemKind::Trait(_, ast::Unsafety::Unsafe, ..) => { self.report_unsafe(cx, it.span, "declaration of an `unsafe` trait") } @@ -391,7 +391,7 @@ fn check_crate(&mut self, cx: &LateContext<'_, '_>, krate: &hir::Crate) { } fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { - let desc = match it.node { + let desc = match it.kind { hir::ItemKind::Fn(..) => "a function", hir::ItemKind::Mod(..) => "a module", hir::ItemKind::Enum(..) => "an enum", @@ -504,7 +504,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) { if !cx.access_levels.is_reachable(item.hir_id) { return; } - let (def, ty) = match item.node { + let (def, ty) = match item.kind { hir::ItemKind::Struct(_, ref ast_generics) => { if !ast_generics.params.is_empty() { return; @@ -563,7 +563,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) { return; } - match item.node { + match item.kind { hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) | hir::ItemKind::Enum(..) => {} @@ -766,7 +766,7 @@ fn warn_if_doc( impl EarlyLintPass for UnusedDocComment { fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) { - if let ast::ItemKind::Mac(..) = item.node { + if let ast::ItemKind::Mac(..) = item.kind { self.warn_if_doc(cx, item.span, "macro expansions", true, &item.attrs); } } @@ -809,7 +809,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { return; } - match it.node { + match it.kind { hir::ItemKind::ExternCrate(..) => (), _ => return, }; @@ -849,7 +849,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems { fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { - match it.node { + match it.kind { hir::ItemKind::Fn(.., ref generics, _) => { if let Some(no_mangle_attr) = attr::find_by_name(&it.attrs, sym::no_mangle) { for param in &generics.params { @@ -992,7 +992,7 @@ fn check_attribute(&mut self, ctx: &LateContext<'_, '_>, attr: &ast::Attribute) impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields { fn check_item(&mut self, ctx: &LateContext<'_, '_>, item: &hir::Item) { - if let hir::ItemKind::Union(ref vdata, _) = item.node { + if let hir::ItemKind::Union(ref vdata, _) = item.kind { for field in vdata.fields() { let field_ty = ctx.tcx.type_of( ctx.tcx.hir().local_def_id(field.hir_id)); @@ -1137,7 +1137,7 @@ fn visit_qpath(&mut self, qpath: &'v hir::QPath, id: hir::HirId, span: Span) { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds { fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) { - let (ty, type_alias_generics) = match item.node { + let (ty, type_alias_generics) = match item.kind { hir::ItemKind::TyAlias(ref ty, ref generics) => (&*ty, generics), _ => return, }; @@ -1204,7 +1204,7 @@ fn check_const(cx: &LateContext<'_, '_>, body_id: hir::BodyId) { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedBrokenConst { fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { - match it.node { + match it.kind { hir::ItemKind::Const(_, body_id) => { check_const(cx, body_id); }, @@ -1395,7 +1395,7 @@ pub fn new() -> Self { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnameableTestItems { fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { if self.items_nameable { - if let hir::ItemKind::Mod(..) = it.node {} + if let hir::ItemKind::Mod(..) = it.kind {} else { self.items_nameable = false; self.boundary = it.hir_id; @@ -1684,7 +1684,7 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) { let def_id = cx.tcx.hir().local_def_id(item.hir_id); if let hir::ItemKind::Struct(_, ref hir_generics) | hir::ItemKind::Enum(_, ref hir_generics) - | hir::ItemKind::Union(_, ref hir_generics) = item.node + | hir::ItemKind::Union(_, ref hir_generics) = item.kind { let inferred_outlives = cx.tcx.inferred_outlives_of(def_id); if inferred_outlives.is_empty() { @@ -1812,7 +1812,7 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) { // generics, except for tuple struct, which have the `where` // after the fields of the struct. let full_where_span = if let hir::ItemKind::Struct(hir::VariantData::Tuple(..), _) - = item.node + = item.kind { where_span } else { diff --git a/src/librustc_lint/nonstandard_style.rs b/src/librustc_lint/nonstandard_style.rs index e1dfe390f19..dceb79fd309 100644 --- a/src/librustc_lint/nonstandard_style.rs +++ b/src/librustc_lint/nonstandard_style.rs @@ -136,7 +136,7 @@ fn check_item(&mut self, cx: &EarlyContext<'_>, it: &ast::Item) { return; } - match it.node { + match it.kind { ast::ItemKind::TyAlias(..) | ast::ItemKind::Enum(..) | ast::ItemKind::Struct(..) | @@ -326,7 +326,7 @@ fn check_fn( } fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { - if let hir::ItemKind::Mod(_) = it.node { + if let hir::ItemKind::Mod(_) = it.kind { self.check_snake_case(cx, "module", &it.ident); } } @@ -387,7 +387,7 @@ fn check_upper_case(cx: &LateContext<'_, '_>, sort: &str, ident: &Ident) { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals { fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { - match it.node { + match it.kind { hir::ItemKind::Static(..) if !attr::contains_name(&it.attrs, sym::no_mangle) => { NonUpperCaseGlobals::check_upper_case(cx, "static variable", &it.ident); } diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index eacfe4be9e5..1fb377c9ad6 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -995,7 +995,7 @@ fn check_foreign_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::ForeignItem impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences { fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) { - if let hir::ItemKind::Enum(ref enum_definition, _) = it.node { + if let hir::ItemKind::Enum(ref enum_definition, _) = it.kind { let item_def_id = cx.tcx.hir().local_def_id(it.hir_id); let t = cx.tcx.type_of(item_def_id); let ty = cx.tcx.erase_regions(&t); diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index d0149b0e909..3b3995832cb 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -647,7 +647,7 @@ fn check_use_tree(&self, cx: &EarlyContext<'_>, use_tree: &ast::UseTree, item: & impl EarlyLintPass for UnusedImportBraces { fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) { - if let ast::ItemKind::Use(ref use_tree) = item.node { + if let ast::ItemKind::Use(ref use_tree) = item.kind { self.check_use_tree(cx, use_tree, item); } } diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index af41b6a4c85..0a2a481bb15 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -999,7 +999,7 @@ pub fn postprocess(&mut self, krate: &ast::Crate) { pub fn process_extern_crate( &mut self, item: &ast::Item, definitions: &Definitions, ) -> CrateNum { - match item.node { + match item.kind { ast::ItemKind::ExternCrate(orig_name) => { debug!("resolving extern crate stmt. ident: {} orig_name: {:?}", item.ident, orig_name); diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 11121ee875d..8a7e599ebeb 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -479,7 +479,7 @@ pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro { id: ast::DUMMY_NODE_ID, span: local_span, attrs: attrs.iter().cloned().collect(), - node: ast::ItemKind::MacroDef(ast::MacroDef { + kind: ast::ItemKind::MacroDef(ast::MacroDef { tokens: body.into(), legacy: def.legacy, }), diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 1c72a8c6ddb..b89da65d098 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -1117,7 +1117,7 @@ fn encode_info_for_item(&mut self, (def_id, item): (DefId, &'tcx hir::Item)) -> debug!("EncodeContext::encode_info_for_item({:?})", def_id); - let kind = match item.node { + let kind = match item.kind { hir::ItemKind::Static(_, hir::MutMutable, _) => EntryKind::MutStatic, hir::ItemKind::Static(_, hir::MutImmutable, _) => EntryKind::ImmStatic, hir::ItemKind::Const(_, body_id) => { @@ -1233,7 +1233,7 @@ fn encode_info_for_item(&mut self, (def_id, item): (DefId, &'tcx hir::Item)) -> hir::ItemKind::Use(..) => bug!("cannot encode info for item {:?}", item), }; - let mir = match item.node { + let mir = match item.kind { hir::ItemKind::Static(..) | hir::ItemKind::Const(..) => true, hir::ItemKind::Fn(_, header, ..) => { let generics = tcx.generics_of(def_id); @@ -1252,7 +1252,7 @@ fn encode_info_for_item(&mut self, (def_id, item): (DefId, &'tcx hir::Item)) -> visibility: self.lazy(ty::Visibility::from_hir(&item.vis, item.hir_id, tcx)), span: self.lazy(item.span), attributes: self.encode_attributes(&item.attrs), - children: match item.node { + children: match item.kind { hir::ItemKind::ForeignMod(ref fm) => { self.lazy(fm.items .iter() @@ -1286,7 +1286,7 @@ fn encode_info_for_item(&mut self, (def_id, item): (DefId, &'tcx hir::Item)) -> stability: self.encode_stability(def_id), deprecation: self.encode_deprecation(def_id), - ty: match item.node { + ty: match item.kind { hir::ItemKind::Static(..) | hir::ItemKind::Const(..) | hir::ItemKind::Fn(..) | @@ -1299,14 +1299,14 @@ fn encode_info_for_item(&mut self, (def_id, item): (DefId, &'tcx hir::Item)) -> _ => None, }, inherent_impls: self.encode_inherent_implementations(def_id), - variances: match item.node { + variances: match item.kind { hir::ItemKind::Enum(..) | hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) | hir::ItemKind::Fn(..) => self.encode_variances_of(def_id), _ => Lazy::empty(), }, - generics: match item.node { + generics: match item.kind { hir::ItemKind::Static(..) | hir::ItemKind::Const(..) | hir::ItemKind::Fn(..) | @@ -1320,7 +1320,7 @@ fn encode_info_for_item(&mut self, (def_id, item): (DefId, &'tcx hir::Item)) -> hir::ItemKind::TraitAlias(..) => Some(self.encode_generics(def_id)), _ => None, }, - predicates: match item.node { + predicates: match item.kind { hir::ItemKind::Static(..) | hir::ItemKind::Const(..) | hir::ItemKind::Fn(..) | @@ -1340,7 +1340,7 @@ fn encode_info_for_item(&mut self, (def_id, item): (DefId, &'tcx hir::Item)) -> // so only encode it in that case as an efficiency // hack. (No reason not to expand it in the future if // necessary.) - predicates_defined_on: match item.node { + predicates_defined_on: match item.kind { hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..) => Some(self.encode_predicates_defined_on(def_id)), _ => None, // not *wrong* for other kinds of items, but not needed @@ -1728,7 +1728,7 @@ fn visit_expr(&mut self, ex: &'tcx hir::Expr) { fn visit_item(&mut self, item: &'tcx hir::Item) { intravisit::walk_item(self, item); let def_id = self.tcx.hir().local_def_id(item.hir_id); - match item.node { + match item.kind { hir::ItemKind::ExternCrate(_) | hir::ItemKind::Use(..) => {} // ignore these _ => self.record(def_id, EncodeContext::encode_info_for_item, (def_id, item)), @@ -1824,7 +1824,7 @@ fn encode_info_for_expr(&mut self, expr: &hir::Expr) { /// normally in the visitor walk. fn encode_addl_info_for_item(&mut self, item: &hir::Item) { let def_id = self.tcx.hir().local_def_id(item.hir_id); - match item.node { + match item.kind { hir::ItemKind::Static(..) | hir::ItemKind::Const(..) | hir::ItemKind::Fn(..) | @@ -1893,7 +1893,7 @@ struct ImplVisitor<'tcx> { impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> { fn visit_item(&mut self, item: &hir::Item) { - if let hir::ItemKind::Impl(..) = item.node { + if let hir::ItemKind::Impl(..) = item.kind { let impl_id = self.tcx.hir().local_def_id(item.hir_id); if let Some(trait_ref) = self.tcx.impl_trait_ref(impl_id) { self.impls diff --git a/src/librustc_metadata/foreign_modules.rs b/src/librustc_metadata/foreign_modules.rs index b2e40282d93..8a4f6e6f17a 100644 --- a/src/librustc_metadata/foreign_modules.rs +++ b/src/librustc_metadata/foreign_modules.rs @@ -19,7 +19,7 @@ struct Collector<'tcx> { impl ItemLikeVisitor<'tcx> for Collector<'tcx> { fn visit_item(&mut self, it: &'tcx hir::Item) { - let fm = match it.node { + let fm = match it.kind { hir::ItemKind::ForeignMod(ref fm) => fm, _ => return, }; diff --git a/src/librustc_metadata/link_args.rs b/src/librustc_metadata/link_args.rs index 728fd004fcb..527d4421fca 100644 --- a/src/librustc_metadata/link_args.rs +++ b/src/librustc_metadata/link_args.rs @@ -27,7 +27,7 @@ struct Collector { impl<'tcx> ItemLikeVisitor<'tcx> for Collector { fn visit_item(&mut self, it: &'tcx hir::Item) { - let fm = match it.node { + let fm = match it.kind { hir::ItemKind::ForeignMod(ref fm) => fm, _ => return, }; diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index ada1a8c615d..fe215d9c799 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -35,7 +35,7 @@ struct Collector<'tcx> { impl ItemLikeVisitor<'tcx> for Collector<'tcx> { fn visit_item(&mut self, it: &'tcx hir::Item) { - let fm = match it.node { + let fm = match it.kind { hir::ItemKind::ForeignMod(ref fm) => fm, _ => return, }; diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 0645e3b96c9..6b7fee6effb 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -28,7 +28,7 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> { // Figure out what primary body this item has. let (body_id, return_ty_span) = match tcx.hir().get(id) { Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. }) - | Node::Item(hir::Item { node: hir::ItemKind::Fn(decl, _, _, body_id), .. }) + | Node::Item(hir::Item { kind: hir::ItemKind::Fn(decl, _, _, body_id), .. }) | Node::ImplItem( hir::ImplItem { kind: hir::ImplItemKind::Method(hir::MethodSig { decl, .. }, body_id), @@ -46,8 +46,8 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> { ) => { (*body_id, decl.output.span()) } - Node::Item(hir::Item { node: hir::ItemKind::Static(ty, _, body_id), .. }) - | Node::Item(hir::Item { node: hir::ItemKind::Const(ty, body_id), .. }) + Node::Item(hir::Item { kind: hir::ItemKind::Static(ty, _, body_id), .. }) + | Node::Item(hir::Item { kind: hir::ItemKind::Const(ty, body_id), .. }) | Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(ty, body_id), .. }) | Node::TraitItem( hir::TraitItem { kind: hir::TraitItemKind::Const(ty, Some(body_id)), .. } diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 2c000f931ef..cc8f4759e18 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -981,7 +981,7 @@ struct RootCollector<'a, 'tcx> { impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> { fn visit_item(&mut self, item: &'v hir::Item) { - match item.node { + match item.kind { hir::ItemKind::ExternCrate(..) | hir::ItemKind::Use(..) | hir::ItemKind::ForeignMod(..) | @@ -1141,7 +1141,7 @@ fn create_mono_items_for_default_impls<'tcx>( item: &'tcx hir::Item, output: &mut Vec>, ) { - match item.node { + match item.kind { hir::ItemKind::Impl(_, _, _, ref generics, .., ref impl_item_refs) => { for param in &generics.params { match param.kind { diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index faec8c7cbe4..acd53ac68ae 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -577,7 +577,7 @@ fn is_enclosed( if used_unsafe.contains(&parent_id) { Some(("block".to_string(), parent_id)) } else if let Some(Node::Item(&hir::Item { - node: hir::ItemKind::Fn(_, header, _, _), + kind: hir::ItemKind::Fn(_, header, _, _), .. })) = tcx.hir().find(parent_id) { match header.unsafety { diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 5ccf73290a6..89497641c10 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -538,7 +538,7 @@ fn visit_item(&mut self, item: &'a Item) { self.has_proc_macro_decls = true; } - match item.node { + match item.kind { ItemKind::Impl(unsafety, polarity, _, _, Some(..), ref ty, ref impl_items) => { self.invalid_visibility(&item.vis, None); if let TyKind::Err = ty.kind { diff --git a/src/librustc_passes/layout_test.rs b/src/librustc_passes/layout_test.rs index 45a185dccf2..06683c16e4a 100644 --- a/src/librustc_passes/layout_test.rs +++ b/src/librustc_passes/layout_test.rs @@ -31,7 +31,7 @@ impl ItemLikeVisitor<'tcx> for VarianceTest<'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { let item_def_id = self.tcx.hir().local_def_id(item.hir_id); - if let ItemKind::TyAlias(..) = item.node { + if let ItemKind::TyAlias(..) = item.kind { for attr in self.tcx.get_attrs(item_def_id).iter() { if attr.check_name(sym::rustc_layout) { self.dump_layout_of(item_def_id, item, attr); diff --git a/src/librustc_plugin/build.rs b/src/librustc_plugin/build.rs index f1bf1111cf7..01559a95c9c 100644 --- a/src/librustc_plugin/build.rs +++ b/src/librustc_plugin/build.rs @@ -15,7 +15,7 @@ struct RegistrarFinder { impl<'v> ItemLikeVisitor<'v> for RegistrarFinder { fn visit_item(&mut self, item: &hir::Item) { - if let hir::ItemKind::Fn(..) = item.node { + if let hir::ItemKind::Fn(..) = item.kind { if attr::contains_name(&item.attrs, sym::plugin_registrar) { self.registrars.push((item.hir_id, item.span)); } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index a72c9e574d0..f44692b7aea 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -240,7 +240,7 @@ fn def_id_visibility<'tcx>( } Node::ImplItem(impl_item) => { match tcx.hir().get(tcx.hir().get_parent_item(hir_id)) { - Node::Item(item) => match &item.node { + Node::Item(item) => match &item.kind { hir::ItemKind::Impl(.., None, _, _) => &impl_item.vis, hir::ItemKind::Impl(.., Some(trait_ref), _, _) => return def_id_visibility(tcx, trait_ref.path.res.def_id()), @@ -572,7 +572,7 @@ fn update_macro_reachable_def( if let ty::Visibility::Public = vis { let item = self.tcx.hir().expect_item(hir_id); if let hir::ItemKind::Struct(ref struct_def, _) - | hir::ItemKind::Union(ref struct_def, _) = item.node + | hir::ItemKind::Union(ref struct_def, _) = item.kind { for field in struct_def.fields() { let field_vis = ty::Visibility::from_hir( @@ -630,12 +630,12 @@ fn update_visibility_of_intermediate_use_statements(&mut self, segments: &[hir:: .and_then(|def_id| self.tcx.hir().as_local_hir_id(def_id)) .map(|module_hir_id| self.tcx.hir().expect_item(module_hir_id)) { - if let hir::ItemKind::Mod(m) = &item.node { + if let hir::ItemKind::Mod(m) = &item.kind { for item_id in m.item_ids.as_ref() { let item = self.tcx.hir().expect_item(item_id.id); let def_id = self.tcx.hir().local_def_id(item_id.id); if !self.tcx.hygienic_eq(segment.ident, item.ident, def_id) { continue; } - if let hir::ItemKind::Use(..) = item.node { + if let hir::ItemKind::Use(..) = item.kind { self.update(item.hir_id, Some(AccessLevel::Exported)); } } @@ -653,7 +653,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { } fn visit_item(&mut self, item: &'tcx hir::Item) { - let inherited_item_level = match item.node { + let inherited_item_level = match item.kind { hir::ItemKind::Impl(..) => Option::::of_impl(item.hir_id, self.tcx, &self.access_levels), // Foreign modules inherit level from parents. @@ -673,7 +673,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) { let item_level = self.update(item.hir_id, inherited_item_level); // Update levels of nested things. - match item.node { + match item.kind { hir::ItemKind::Enum(ref def, _) => { for variant in &def.variants { let variant_level = self.update(variant.id, item_level); @@ -727,7 +727,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) { } // Mark all items in interfaces of reachable items as reachable. - match item.node { + match item.kind { // The interface is empty. hir::ItemKind::ExternCrate(..) => {} // All nested items are checked by `visit_item`. @@ -1417,7 +1417,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { } fn visit_item(&mut self, item: &'tcx hir::Item) { - match item.node { + match item.kind { // Contents of a private mod can be re-exported, so we need // to check internals. hir::ItemKind::Mod(_) => {} @@ -1853,7 +1853,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) { let tcx = self.tcx; let item_visibility = ty::Visibility::from_hir(&item.vis, item.hir_id, tcx); - match item.node { + match item.kind { // Crates are always public. hir::ItemKind::ExternCrate(..) => {} // All nested items are checked by `visit_item`. diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index bd0606cb670..f1564c30018 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -588,7 +588,7 @@ fn build_reduced_graph_for_item(&mut self, item: &'b Item) { let sp = item.span; let vis = self.resolve_visibility(&item.vis); - match item.node { + match item.kind { ItemKind::Use(ref use_tree) => { self.build_reduced_graph_for_use_tree( // This particular use tree @@ -936,7 +936,7 @@ fn process_legacy_macro_imports(&mut self, item: &Item, module: Module<'a>) -> b span_err!(self.r.session, item.span, E0468, "an `extern crate` loading macros must be at the crate root"); } - if let ItemKind::ExternCrate(Some(orig_name)) = item.node { + if let ItemKind::ExternCrate(Some(orig_name)) = item.kind { if orig_name == kw::SelfLower { self.r.session.span_err(attr.span, "`macro_use` is not supported on `extern crate self`"); @@ -1064,7 +1064,7 @@ fn proc_macro_stub(item: &ast::Item) -> Option<(MacroKind, Ident, Span)> { fn define_macro(&mut self, item: &ast::Item) -> LegacyScope<'a> { let parent_scope = &self.parent_scope; let expansion = parent_scope.expansion; - let (ext, ident, span, is_legacy) = match &item.node { + let (ext, ident, span, is_legacy) = match &item.kind { ItemKind::MacroDef(def) => { let ext = Lrc::new(self.r.compile_macro(item, self.r.session.edition())); (ext, item.ident, item.span, def.legacy) @@ -1138,7 +1138,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { method!(visit_ty: ast::Ty, ast::TyKind::Mac, walk_ty); fn visit_item(&mut self, item: &'b Item) { - let macro_use = match item.node { + let macro_use = match item.kind { ItemKind::MacroDef(..) => { self.parent_scope.legacy = self.define_macro(item); return diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs index 0d85be83e12..737589acf8d 100644 --- a/src/librustc_resolve/check_unused.rs +++ b/src/librustc_resolve/check_unused.rs @@ -103,7 +103,7 @@ fn visit_item(&mut self, item: &'a ast::Item) { // whether they're used or not. Also ignore imports with a dummy span // because this means that they were generated in some fashion by the // compiler and we don't need to consider them. - if let ast::ItemKind::Use(..) = item.node { + if let ast::ItemKind::Use(..) = item.kind { if item.vis.node.is_pub() || item.span.is_dummy() { return; } diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index 3f66829e8f8..e02cba6fbfd 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -700,9 +700,9 @@ fn future_proof_import(&mut self, use_tree: &UseTree) { fn resolve_item(&mut self, item: &Item) { let name = item.ident.name; - debug!("(resolving item) resolving {} ({:?})", name, item.node); + debug!("(resolving item) resolving {} ({:?})", name, item.kind); - match item.node { + match item.kind { ItemKind::TyAlias(_, ref generics) | ItemKind::OpaqueTy(_, ref generics) | ItemKind::Fn(_, _, ref generics, _) => { @@ -1805,7 +1805,7 @@ fn resolve_block(&mut self, block: &Block) { // Descend into the block. for stmt in &block.stmts { if let StmtKind::Item(ref item) = stmt.kind { - if let ItemKind::MacroDef(..) = item.node { + if let ItemKind::MacroDef(..) = item.kind { num_macro_definition_ribs += 1; let res = self.r.definitions.local_def_id(item.id); self.ribs[ValueNS].push(Rib::new(MacroDefinition(res))); diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 74f68e51471..bf86a374338 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -290,7 +290,7 @@ fn visit_mod( } // find a use statement for item in &module.items { - match item.node { + match item.kind { ItemKind::Use(..) => { // don't suggest placing a use before the prelude // import or other generated ones diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index c24552678eb..d81d24e3a1b 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -472,13 +472,13 @@ fn process_struct( let qualname = format!("::{}", self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id))); - let kind = match item.node { + let kind = match item.kind { ast::ItemKind::Struct(_, _) => DefKind::Struct, ast::ItemKind::Union(_, _) => DefKind::Union, _ => unreachable!(), }; - let (value, fields) = match item.node { + let (value, fields) = match item.kind { ast::ItemKind::Struct(ast::VariantData::Struct(ref fields, ..), ..) | ast::ItemKind::Union(ast::VariantData::Struct(ref fields, ..), ..) => { let include_priv_fields = !self.save_ctxt.config.pub_only; @@ -1276,7 +1276,7 @@ fn visit_mod(&mut self, m: &'l ast::Mod, span: Span, attrs: &[ast::Attribute], i fn visit_item(&mut self, item: &'l ast::Item) { use syntax::ast::ItemKind::*; self.process_macro_use(item.span); - match item.node { + match item.kind { Use(ref use_tree) => { let prefix = ast::Path { segments: vec![], diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index bc067ab6ba5..20cf7949fec 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -177,7 +177,7 @@ pub fn get_extern_item_data(&self, item: &ast::ForeignItem) -> Option { } pub fn get_item_data(&self, item: &ast::Item) -> Option { - match item.node { + match item.kind { ast::ItemKind::Fn(ref decl, .., ref generics, _) => { let qualname = format!("::{}", self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id))); @@ -396,7 +396,7 @@ pub fn get_method_data(&self, id: ast::NodeId, ident: ast::Ident, span: Span) -> let (qualname, parent_scope, decl_id, docs, attributes) = match self.tcx.impl_of_method(self.tcx.hir().local_def_id_from_node_id(id)) { Some(impl_id) => match self.tcx.hir().get_if_local(impl_id) { - Some(Node::Item(item)) => match item.node { + Some(Node::Item(item)) => match item.kind { hir::ItemKind::Impl(.., ref ty, _) => { let mut qualname = String::from("<"); qualname.push_str(&self.tcx.hir().hir_to_pretty_string(ty.hir_id)); @@ -612,7 +612,7 @@ pub fn get_path_res(&self, id: NodeId) -> Res { Node::TraitRef(tr) => tr.path.res, Node::Item(&hir::Item { - node: hir::ItemKind::Use(ref path, _), + kind: hir::ItemKind::Use(ref path, _), .. }) | Node::Visibility(&Spanned { diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index 87417f577a1..8a0c9069224 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -324,7 +324,7 @@ impl Sig for ast::Item { fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext<'_, '_>) -> Result { let id = Some(self.id); - match self.node { + match self.kind { ast::ItemKind::Static(ref ty, m, ref expr) => { let mut text = "static ".to_owned(); if m == ast::Mutability::Mutable { diff --git a/src/librustc_traits/lowering/environment.rs b/src/librustc_traits/lowering/environment.rs index 6eec7158e47..f923f51529a 100644 --- a/src/librustc_traits/lowering/environment.rs +++ b/src/librustc_traits/lowering/environment.rs @@ -205,7 +205,7 @@ enum NodeKind { _ => NodeKind::Other, } - Node::Item(item) => match item.node { + Node::Item(item) => match item.kind { ItemKind::Impl(.., Some(..), _, _) => NodeKind::TraitImpl, ItemKind::Impl(.., None, _, _) => NodeKind::InherentImpl, ItemKind::Fn(..) => NodeKind::Fn, diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 019a82350bd..13b6b1b8aa0 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -248,7 +248,7 @@ fn maybe_get_coercion_reason(&self, hir_id: hir::HirId, span: Span) -> Option<(S ), ); if let (Some(expr), Item(hir::Item { - node: hir::ItemKind::Fn(..), .. + kind: hir::ItemKind::Fn(..), .. })) = (&block.expr, parent) { // check that the `if` expr without `else` is the fn body's expr if expr.span == span { diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 4b02bc58d66..2d4d2e32f23 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -895,7 +895,7 @@ struct Visitor<'a, 'tcx> { impl<'v, 'a, 'tcx> itemlikevisit::ItemLikeVisitor<'v> for Visitor<'a, 'tcx> { fn visit_item(&mut self, i: &'v hir::Item) { - match i.node { + match i.kind { hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..) => { let def_id = self.map.local_def_id(i.hir_id); @@ -999,7 +999,7 @@ fn visit_mod( // Find a `use` statement. for item_id in &module.item_ids { let item = self.tcx.hir().expect_item(item_id.id); - match item.node { + match item.kind { hir::ItemKind::Use(..) => { // Don't suggest placing a `use` before the prelude // import or other generated ones. diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 91297d6ecd0..15c98432cc2 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -792,7 +792,7 @@ fn primary_body_of( ) -> Option<(hir::BodyId, Option<&hir::Ty>, Option<&hir::FnHeader>, Option<&hir::FnDecl>)> { match tcx.hir().get(id) { Node::Item(item) => { - match item.node { + match item.kind { hir::ItemKind::Const(ref ty, body) | hir::ItemKind::Static(ref ty, _, body) => Some((body, Some(ty), None, None)), @@ -1262,7 +1262,7 @@ fn check_fn<'a, 'tcx>( } if let Node::Item(item) = fcx.tcx.hir().get(fn_id) { - if let ItemKind::Fn(_, _, ref generics, _) = item.node { + if let ItemKind::Fn(_, _, ref generics, _) = item.kind { if !generics.params.is_empty() { fcx.tcx.sess.span_err( span, @@ -1310,7 +1310,7 @@ fn check_fn<'a, 'tcx>( } if let Node::Item(item) = fcx.tcx.hir().get(fn_id) { - if let ItemKind::Fn(_, _, ref generics, _) = item.node { + if let ItemKind::Fn(_, _, ref generics, _) = item.kind { if !generics.params.is_empty() { fcx.tcx.sess.span_err( span, @@ -1403,7 +1403,7 @@ fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool { } } - let prohibit_opaque = match item.node { + let prohibit_opaque = match item.kind { ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::AsyncFn, .. }) | ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::FnReturn, .. }) => { let mut visitor = ProhibitOpaqueVisitor { @@ -1421,7 +1421,7 @@ fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool { debug!("check_opaque_for_inheriting_lifetimes: prohibit_opaque={:?}", prohibit_opaque); if prohibit_opaque { - let is_async = match item.node { + let is_async = match item.kind { ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => match origin { hir::OpaqueTyOrigin::AsyncFn => true, _ => false, @@ -1485,7 +1485,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item) { tcx.def_path_str(tcx.hir().local_def_id(it.hir_id)) ); let _indenter = indenter(); - match it.node { + match it.kind { // Consts can play a role in type-checking, so they are included here. hir::ItemKind::Static(..) => { let def_id = tcx.hir().local_def_id(it.hir_id); @@ -4069,7 +4069,7 @@ fn parent_item_span(&self, id: hir::HirId) -> Option { let node = self.tcx.hir().get(self.tcx.hir().get_parent_item(id)); match node { Node::Item(&hir::Item { - node: hir::ItemKind::Fn(_, _, _, body_id), .. + kind: hir::ItemKind::Fn(_, _, _, body_id), .. }) | Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Method(_, body_id), .. @@ -4094,7 +4094,7 @@ fn get_parent_fn_decl(&self, blk_id: hir::HirId) -> Option<(&'tcx hir::FnDecl, a fn get_node_fn_decl(&self, node: Node<'tcx>) -> Option<(&'tcx hir::FnDecl, ast::Ident, bool)> { match node { Node::Item(&hir::Item { - ident, node: hir::ItemKind::Fn(ref decl, ..), .. + ident, kind: hir::ItemKind::Fn(ref decl, ..), .. }) => { // This is less than ideal, it will not suggest a return type span on any // method called `main`, regardless of whether it is actually the entry point, @@ -4192,7 +4192,7 @@ fn suggest_fn_call( let mut msg = "call this function"; match hir.get_if_local(def_id) { Some(Node::Item(hir::Item { - node: ItemKind::Fn(.., body_id), + kind: ItemKind::Fn(.., body_id), .. })) | Some(Node::ImplItem(hir::ImplItem { diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 732499cae14..d5577778950 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -76,7 +76,7 @@ pub fn check_item_well_formed(tcx: TyCtxt<'_>, def_id: DefId) { item.hir_id, tcx.def_path_str(def_id)); - match item.node { + match item.kind { // Right now we check that every default trait implementation // has an implementation of itself. Basically, a case like: // @@ -299,7 +299,7 @@ fn check_type_defn<'tcx, F>( field.span, fcx.body_id, traits::FieldSized { - adt_kind: match item.node.adt_kind() { + adt_kind: match item.kind.adt_kind() { Some(i) => i, None => bug!(), }, diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs index ffc66ec16de..7af1a342ff3 100644 --- a/src/librustc_typeck/check_unused.rs +++ b/src/librustc_typeck/check_unused.rs @@ -33,7 +33,7 @@ fn visit_item(&mut self, item: &hir::Item) { if item.vis.node.is_pub() || item.span.is_dummy() { return; } - if let hir::ItemKind::Use(ref path, _) = item.node { + if let hir::ItemKind::Use(ref path, _) = item.kind { self.check_import(item.hir_id, path.span); } } @@ -218,7 +218,7 @@ struct ExternCrateToLint { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CollectExternCrateVisitor<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { - if let hir::ItemKind::ExternCrate(orig_name) = item.node { + if let hir::ItemKind::ExternCrate(orig_name) = item.kind { let extern_crate_def_id = self.tcx.hir().local_def_id(item.hir_id); self.crates_to_lint.push( ExternCrateToLint { diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs index 9054c2b8010..64bd144dfa2 100644 --- a/src/librustc_typeck/coherence/builtin.rs +++ b/src/librustc_typeck/coherence/builtin.rs @@ -53,7 +53,7 @@ fn visit_implementation_of_drop(tcx: TyCtxt<'_>, impl_did: DefId) { // Destructors only work on nominal types. if let Some(impl_hir_id) = tcx.hir().as_local_hir_id(impl_did) { if let Some(Node::Item(item)) = tcx.hir().find(impl_hir_id) { - let span = match item.node { + let span = match item.kind { ItemKind::Impl(.., ref ty, _) => ty.span, _ => item.span, }; @@ -99,7 +99,7 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: DefId) { Ok(()) => {} Err(CopyImplementationError::InfrigingFields(fields)) => { let item = tcx.hir().expect_item(impl_hir_id); - let span = if let ItemKind::Impl(.., Some(ref tr), _, _) = item.node { + let span = if let ItemKind::Impl(.., Some(ref tr), _, _) = item.kind { tr.path.span } else { span @@ -116,7 +116,7 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: DefId) { } Err(CopyImplementationError::NotAnAdt) => { let item = tcx.hir().expect_item(impl_hir_id); - let span = if let ItemKind::Impl(.., ref ty, _) = item.node { + let span = if let ItemKind::Impl(.., ref ty, _) = item.kind { ty.span } else { span @@ -481,7 +481,7 @@ pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn return err_info; } else if diff_fields.len() > 1 { let item = gcx.hir().expect_item(impl_hir_id); - let span = if let ItemKind::Impl(.., Some(ref t), _, _) = item.node { + let span = if let ItemKind::Impl(.., Some(ref t), _, _) = item.kind { t.path.span } else { gcx.hir().span(impl_hir_id) diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs index d2651317da9..90cedb455e3 100644 --- a/src/librustc_typeck/coherence/inherent_impls.rs +++ b/src/librustc_typeck/coherence/inherent_impls.rs @@ -49,7 +49,7 @@ struct InherentCollect<'tcx> { impl ItemLikeVisitor<'v> for InherentCollect<'tcx> { fn visit_item(&mut self, item: &hir::Item) { - let ty = match item.node { + let ty = match item.kind { hir::ItemKind::Impl(.., None, ref ty, _) => ty, _ => return }; diff --git a/src/librustc_typeck/coherence/inherent_impls_overlap.rs b/src/librustc_typeck/coherence/inherent_impls_overlap.rs index 04b59a63e1d..0aae8fbe131 100644 --- a/src/librustc_typeck/coherence/inherent_impls_overlap.rs +++ b/src/librustc_typeck/coherence/inherent_impls_overlap.rs @@ -84,7 +84,7 @@ fn check_for_overlapping_inherent_impls(&self, ty_def_id: DefId) { impl ItemLikeVisitor<'v> for InherentOverlapChecker<'tcx> { fn visit_item(&mut self, item: &'v hir::Item) { - match item.node { + match item.kind { hir::ItemKind::Enum(..) | hir::ItemKind::Struct(..) | hir::ItemKind::Trait(..) | diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 8969bf894e0..667fa50a7cf 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -24,7 +24,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> { fn visit_item(&mut self, item: &hir::Item) { let def_id = self.tcx.hir().local_def_id(item.hir_id); // "Trait" impl - if let hir::ItemKind::Impl(.., Some(_), _, _) = item.node { + if let hir::ItemKind::Impl(.., Some(_), _, _) = item.kind { debug!("coherence2::orphan check: trait impl {}", self.tcx.hir().node_to_string(item.hir_id)); let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap(); diff --git a/src/librustc_typeck/coherence/unsafety.rs b/src/librustc_typeck/coherence/unsafety.rs index 07fbfddd96e..b7cc6feee44 100644 --- a/src/librustc_typeck/coherence/unsafety.rs +++ b/src/librustc_typeck/coherence/unsafety.rs @@ -71,7 +71,7 @@ fn check_unsafety_coherence(&mut self, impl ItemLikeVisitor<'v> for UnsafetyChecker<'tcx> { fn visit_item(&mut self, item: &'v hir::Item) { - if let hir::ItemKind::Impl(unsafety, polarity, _, ref generics, ..) = item.node { + if let hir::ItemKind::Impl(unsafety, polarity, _, ref generics, ..) = item.kind { self.check_unsafety_coherence(item, Some(generics), unsafety, polarity); } } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 019f39ed6e1..28c275e2d75 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -288,7 +288,7 @@ fn type_param_predicates( Node::ImplItem(item) => &item.generics, Node::Item(item) => { - match item.node { + match item.kind { ItemKind::Fn(.., ref generics, _) | ItemKind::Impl(_, _, _, ref generics, ..) | ItemKind::TyAlias(_, ref generics) @@ -403,7 +403,7 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) { let it = tcx.hir().expect_item(item_id); debug!("convert: item {} with id {}", it.ident, it.hir_id); let def_id = tcx.hir().local_def_id(item_id); - match it.node { + match it.kind { // These don't define types. hir::ItemKind::ExternCrate(_) | hir::ItemKind::Use(..) @@ -474,7 +474,7 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) { tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); - if let hir::ItemKind::Fn(..) = it.node { + if let hir::ItemKind::Fn(..) = it.kind { tcx.fn_sig(def_id); } } @@ -638,7 +638,7 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::AdtDef { }; let repr = ReprOptions::new(tcx, def_id); - let (kind, variants) = match item.node { + let (kind, variants) = match item.kind { ItemKind::Enum(ref def, _) => { let mut distance_from_explicit = 0; let variants = def.variants @@ -707,7 +707,7 @@ fn super_predicates_of( _ => bug!("trait_node_id {} is not an item", trait_hir_id), }; - let (generics, bounds) = match item.node { + let (generics, bounds) = match item.kind { hir::ItemKind::Trait(.., ref generics, ref supertraits, _) => (generics, supertraits), hir::ItemKind::TraitAlias(ref generics, ref supertraits) => (generics, supertraits), _ => span_bug!(item.span, "super_predicates invoked on non-trait"), @@ -753,7 +753,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::TraitDef { let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); let item = tcx.hir().expect_item(hir_id); - let (is_auto, unsafety) = match item.node { + let (is_auto, unsafety) = match item.kind { hir::ItemKind::Trait(is_auto, unsafety, ..) => (is_auto == hir::IsAuto::Yes, unsafety), hir::ItemKind::TraitAlias(..) => (false, hir::Unsafety::Normal), _ => span_bug!(item.span, "trait_def_of_item invoked on non-trait"), @@ -878,7 +878,7 @@ fn has_late_bound_regions<'tcx>( } _ => None, }, - Node::Item(item) => match item.node { + Node::Item(item) => match item.kind { hir::ItemKind::Fn(ref fn_decl, .., ref generics, _) => { has_late_bound_regions(tcx, generics, fn_decl) } @@ -918,7 +918,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics { kind: hir::ExprKind::Closure(..), .. }) => Some(tcx.closure_base_def_id(def_id)), - Node::Item(item) => match item.node { + Node::Item(item) => match item.kind { ItemKind::OpaqueTy(hir::OpaqueTy { impl_trait_fn, .. }) => impl_trait_fn, _ => None, }, @@ -935,7 +935,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics { Node::ImplItem(item) => &item.generics, Node::Item(item) => { - match item.node { + match item.kind { ItemKind::Fn(.., ref generics, _) | ItemKind::Impl(_, _, _, ref generics, ..) => { generics } @@ -1265,7 +1265,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option { - match item.node { + match item.kind { ItemKind::Static(ref ty, .., body_id) | ItemKind::Const(ref ty, body_id) => { if let hir::TyKind::Infer = ty.kind { @@ -1325,7 +1325,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option, def_id: DefId) -> ty::PolyFnSig<'_> { .. }) | Item(hir::Item { - node: ItemKind::Fn(decl, header, _, _), + kind: ItemKind::Fn(decl, header, _, _), .. }) => match get_infer_ret_ty(&decl.output) { Some(ty) => { @@ -1878,7 +1878,7 @@ fn impl_trait_ref(tcx: TyCtxt<'_>, def_id: DefId) -> Option> { let icx = ItemCtxt::new(tcx, def_id); let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); - match tcx.hir().expect_item(hir_id).node { + match tcx.hir().expect_item(hir_id).kind { hir::ItemKind::Impl(.., ref opt_trait_ref, _, _) => { opt_trait_ref.as_ref().map(|ast_trait_ref| { let selfty = tcx.type_of(def_id); @@ -1893,7 +1893,7 @@ fn impl_polarity(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ImplPolarity { let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); let is_rustc_reservation = tcx.has_attr(def_id, sym::rustc_reservation_impl); let item = tcx.hir().expect_item(hir_id); - match &item.node { + match &item.kind { hir::ItemKind::Impl(_, hir::ImplPolarity::Negative, ..) => { if is_rustc_reservation { tcx.sess.span_err(item.span, "reservation impls can't be negative"); @@ -2076,7 +2076,7 @@ fn extend, Span)>>(&mut self, iter: }, Node::Item(item) => { - match item.node { + match item.kind { ItemKind::Impl(_, _, defaultness, ref generics, ..) => { if defaultness.is_default() { is_default_impl_trait = tcx.impl_trait_ref(def_id); @@ -2310,7 +2310,7 @@ fn extend, Span)>>(&mut self, iter: // in trait checking. See `setup_constraining_predicates` // for details. if let Node::Item(&Item { - node: ItemKind::Impl(..), + kind: ItemKind::Impl(..), .. }) = node { @@ -2417,7 +2417,7 @@ fn is_foreign_item(tcx: TyCtxt<'_>, def_id: DefId) -> bool { fn static_mutability(tcx: TyCtxt<'_>, def_id: DefId) -> Option { match tcx.hir().get_if_local(def_id) { Some(Node::Item(&hir::Item { - node: hir::ItemKind::Static(_, mutbl, _), .. + kind: hir::ItemKind::Static(_, mutbl, _), .. })) | Some(Node::ForeignItem( &hir::ForeignItem { node: hir::ForeignItemKind::Static(_, mutbl), .. diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index 8f661112caa..ab660caa222 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -78,7 +78,7 @@ struct ImplWfCheck<'tcx> { impl ItemLikeVisitor<'tcx> for ImplWfCheck<'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { - if let hir::ItemKind::Impl(.., ref impl_item_refs) = item.node { + if let hir::ItemKind::Impl(.., ref impl_item_refs) = item.kind { let impl_def_id = self.tcx.hir().local_def_id(item.hir_id); enforce_impl_params_are_constrained(self.tcx, impl_def_id, diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index dbff1e91617..00be1c84599 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -162,7 +162,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) { match main_t.kind { ty::FnDef(..) => { if let Some(Node::Item(it)) = tcx.hir().find(main_id) { - if let hir::ItemKind::Fn(.., ref generics, _) = it.node { + if let hir::ItemKind::Fn(.., ref generics, _) = it.kind { let mut error = false; if !generics.params.is_empty() { let msg = "`main` function is not allowed to have generic \ @@ -227,7 +227,7 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) { match start_t.kind { ty::FnDef(..) => { if let Some(Node::Item(it)) = tcx.hir().find(start_id) { - if let hir::ItemKind::Fn(.., ref generics, _) = it.node { + if let hir::ItemKind::Fn(.., ref generics, _) = it.kind { let mut error = false; if !generics.params.is_empty() { struct_span_err!(tcx.sess, generics.span, E0132, diff --git a/src/librustc_typeck/outlives/implicit_infer.rs b/src/librustc_typeck/outlives/implicit_infer.rs index 88091d0da0e..433d04ffa64 100644 --- a/src/librustc_typeck/outlives/implicit_infer.rs +++ b/src/librustc_typeck/outlives/implicit_infer.rs @@ -66,7 +66,7 @@ fn visit_item(&mut self, item: &hir::Item) { }; let mut item_required_predicates = RequiredPredicates::default(); - match item.node { + match item.kind { hir::ItemKind::Union(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Struct(..) => { let adt_def = self.tcx.adt_def(item_did); diff --git a/src/librustc_typeck/outlives/mod.rs b/src/librustc_typeck/outlives/mod.rs index 59aac5c7ffd..cdb83eb328a 100644 --- a/src/librustc_typeck/outlives/mod.rs +++ b/src/librustc_typeck/outlives/mod.rs @@ -30,7 +30,7 @@ fn inferred_outlives_of( .expect("expected local def-id"); match tcx.hir().get(id) { - Node::Item(item) => match item.node { + Node::Item(item) => match item.kind { hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Union(..) => { let crate_map = tcx.inferred_outlives_crate(LOCAL_CRATE); diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 2bd00172efb..4dcb467e32b 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -68,7 +68,7 @@ pub fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>) impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { - match item.node { + match item.kind { hir::ItemKind::Struct(ref struct_def, _) | hir::ItemKind::Union(ref struct_def, _) => { self.visit_node_helper(item.hir_id); diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index 8145a97a020..b3c0bee50f3 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -49,7 +49,7 @@ fn variances_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[ty::Variance] { span_bug!(tcx.hir().span(id), "asked to compute variance for wrong kind of item") }; match tcx.hir().get(id) { - Node::Item(item) => match item.node { + Node::Item(item) => match item.kind { hir::ItemKind::Enum(..) | hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) | diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index 3511a659622..0489cd90c83 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -131,7 +131,7 @@ fn visit_item(&mut self, item: &hir::Item) { debug!("add_inferreds for item {}", self.tcx.hir().node_to_string(item.hir_id)); - match item.node { + match item.kind { hir::ItemKind::Struct(ref struct_def, _) | hir::ItemKind::Union(ref struct_def, _) => { self.add_inferreds_for_item(item.hir_id); diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 479c8c37283..532c5f67bf3 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -333,7 +333,7 @@ pub fn build_impl(cx: &DocContext<'_>, did: DefId, attrs: Option>, } let for_ = if let Some(hir_id) = tcx.hir().as_local_hir_id(did) { - match tcx.hir().expect_item(hir_id).node { + match tcx.hir().expect_item(hir_id).kind { hir::ItemKind::Impl(.., ref t, _) => { t.clean(cx) } @@ -355,7 +355,7 @@ pub fn build_impl(cx: &DocContext<'_>, did: DefId, attrs: Option>, let predicates = tcx.explicit_predicates_of(did); let (trait_items, generics) = if let Some(hir_id) = tcx.hir().as_local_hir_id(did) { - match tcx.hir().expect_item(hir_id).node { + match tcx.hir().expect_item(hir_id).kind { hir::ItemKind::Impl(.., ref gen, _, _, ref item_ids) => { ( item_ids.iter() @@ -481,7 +481,7 @@ fn build_macro(cx: &DocContext<'_>, did: DefId, name: ast::Name) -> clean::ItemE let imported_from = cx.tcx.original_crate_name(did.krate); match cx.cstore.load_macro_untracked(did, cx.sess()) { LoadedMacro::MacroDef(def) => { - let matchers: hir::HirVec = if let ast::ItemKind::MacroDef(ref def) = def.node { + let matchers: hir::HirVec = if let ast::ItemKind::MacroDef(ref def) = def.kind { let tts: Vec<_> = def.stream().into_trees().collect(); tts.chunks(4).map(|arm| arm[0].span()).collect() } else { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 161b1a996a9..026a76f0894 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -275,7 +275,7 @@ fn clean(&self, cx: &DocContext<'_>) -> ExternalCrate { let primitives = if root.is_local() { cx.tcx.hir().krate().module.item_ids.iter().filter_map(|&id| { let item = cx.tcx.hir().expect_item(id.id); - match item.node { + match item.kind { hir::ItemKind::Mod(_) => { as_primitive(Res::Def( DefKind::Mod, @@ -319,7 +319,7 @@ fn clean(&self, cx: &DocContext<'_>) -> ExternalCrate { let keywords = if root.is_local() { cx.tcx.hir().krate().module.item_ids.iter().filter_map(|&id| { let item = cx.tcx.hir().expect_item(id.id); - match item.node { + match item.kind { hir::ItemKind::Mod(_) => { as_keyword(Res::Def( DefKind::Mod, @@ -2868,7 +2868,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Type { TyKind::Tup(ref tys) => Tuple(tys.clean(cx)), TyKind::Def(item_id, _) => { let item = cx.tcx.hir().expect_item(item_id.id); - if let hir::ItemKind::OpaqueTy(ref ty) = item.node { + if let hir::ItemKind::OpaqueTy(ref ty) = item.kind { ImplTrait(ty.bounds.clean(cx)) } else { unreachable!() @@ -2889,7 +2889,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Type { // Substitute private type aliases if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(def_id) { if !cx.renderinfo.borrow().access_levels.is_exported(def_id) { - alias = Some(&cx.tcx.hir().expect_item(hir_id).node); + alias = Some(&cx.tcx.hir().expect_item(hir_id).kind); } } }; diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 424239c9982..6576165b6ce 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -425,7 +425,7 @@ pub fn make_test(s: &str, match parser.parse_item() { Ok(Some(item)) => { if !found_main { - if let ast::ItemKind::Fn(..) = item.node { + if let ast::ItemKind::Fn(..) = item.kind { if item.ident.name == sym::main { found_main = true; } @@ -433,7 +433,7 @@ pub fn make_test(s: &str, } if !found_extern_crate { - if let ast::ItemKind::ExternCrate(original) = item.node { + if let ast::ItemKind::ExternCrate(original) = item.kind { // This code will never be reached if `cratename` is none because // `found_extern_crate` is initialized to `true` if it is none. let cratename = cratename.unwrap(); @@ -446,7 +446,7 @@ pub fn make_test(s: &str, } if !found_macro { - if let ast::ItemKind::Mac(..) = item.node { + if let ast::ItemKind::Mac(..) = item.kind { found_macro = true; } } @@ -882,7 +882,7 @@ fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'thi } fn visit_item(&mut self, item: &'hir hir::Item) { - let name = if let hir::ItemKind::Impl(.., ref ty, _) = item.node { + let name = if let hir::ItemKind::Impl(.., ref ty, _) = item.kind { self.map.hir_to_pretty_string(ty.hir_id) } else { item.ident.to_string() diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index ee330cb3211..8cf5fbe849f 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -320,7 +320,7 @@ fn inherits_doc_hidden(cx: &core::DocContext<'_>, mut node: hir::HirId) -> bool if !self.view_item_stack.insert(res_hir_id) { return false } let ret = match tcx.hir().get(res_hir_id) { - Node::Item(&hir::Item { node: hir::ItemKind::Mod(ref m), .. }) if glob => { + Node::Item(&hir::Item { kind: hir::ItemKind::Mod(ref m), .. }) if glob => { let prev = mem::replace(&mut self.inlining, true); for i in &m.item_ids { let i = self.cx.tcx.hir().expect_item(i.id); @@ -361,7 +361,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item, self.store_path(def_id); } - match item.node { + match item.kind { hir::ItemKind::ForeignMod(ref fm) => { for item in &fm.items { self.visit_foreign_item(item, None, om); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 684a2f15c62..15b30352e46 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -2269,7 +2269,7 @@ pub struct Item { pub ident: Ident, pub attrs: Vec, pub id: NodeId, - pub node: ItemKind, + pub kind: ItemKind, pub vis: Visibility, pub span: Span, diff --git a/src/libsyntax/entry.rs b/src/libsyntax/entry.rs index 0b6cf30bd27..34b5b1e5b5c 100644 --- a/src/libsyntax/entry.rs +++ b/src/libsyntax/entry.rs @@ -13,7 +13,7 @@ pub enum EntryPointType { // Beware, this is duplicated in librustc/middle/entry.rs, make sure to keep // them in sync. pub fn entry_point_type(item: &Item, depth: usize) -> EntryPointType { - match item.node { + match item.kind { ItemKind::Fn(..) => { if attr::contains_name(&item.attrs, sym::start) { EntryPointType::Start diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 692849eb8cf..54cfb80573e 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -222,7 +222,7 @@ pub fn expect_variant(self) -> ast::Variant { pub fn derive_allowed(&self) -> bool { match *self { - Annotatable::Item(ref item) => match item.node { + Annotatable::Item(ref item) => match item.kind { ast::ItemKind::Struct(..) | ast::ItemKind::Enum(..) | ast::ItemKind::Union(..) => true, diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index a2a7571c440..6b93d045588 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -567,14 +567,14 @@ pub fn fn_decl(&self, inputs: Vec, output: ast::FunctionRetTy) -> P< } pub fn item(&self, span: Span, name: Ident, - attrs: Vec, node: ast::ItemKind) -> P { + attrs: Vec, kind: ast::ItemKind) -> P { // FIXME: Would be nice if our generated code didn't violate // Rust coding conventions P(ast::Item { ident: name, attrs, id: ast::DUMMY_NODE_ID, - node, + kind, vis: respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited), span, tokens: None, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index d90839ac7fd..bc073a66795 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -293,7 +293,7 @@ pub fn expand_crate(&mut self, mut krate: ast::Crate) -> ast::Crate { let krate_item = AstFragment::Items(smallvec![P(ast::Item { attrs: krate.attrs, span: krate.span, - node: ast::ItemKind::Mod(krate.module), + kind: ast::ItemKind::Mod(krate.module), ident: Ident::invalid(), id: ast::DUMMY_NODE_ID, vis: respan(krate.span.shrink_to_lo(), ast::VisibilityKind::Public), @@ -301,7 +301,7 @@ pub fn expand_crate(&mut self, mut krate: ast::Crate) -> ast::Crate { })]); match self.fully_expand_fragment(krate_item).make_items().pop().map(P::into_inner) { - Some(ast::Item { attrs, node: ast::ItemKind::Mod(module), .. }) => { + Some(ast::Item { attrs, kind: ast::ItemKind::Mod(module), .. }) => { krate.attrs = attrs; krate.module = module; }, @@ -689,7 +689,7 @@ fn extract_proc_macro_attr_input(&self, tokens: TokenStream, span: Span) -> Toke fn gate_proc_macro_attr_item(&self, span: Span, item: &Annotatable) { let (kind, gate) = match *item { Annotatable::Item(ref item) => { - match item.node { + match item.kind { ItemKind::Mod(_) if self.cx.ecfg.proc_macro_hygiene() => return, ItemKind::Mod(_) => ("modules", sym::proc_macro_hygiene), _ => return, @@ -737,7 +737,7 @@ struct DisallowMacros<'a> { impl<'ast, 'a> Visitor<'ast> for DisallowMacros<'a> { fn visit_item(&mut self, i: &'ast ast::Item) { - if let ast::ItemKind::MacroDef(_) = i.node { + if let ast::ItemKind::MacroDef(_) = i.kind { emit_feature_err( self.parse_sess, sym::proc_macro_hygiene, @@ -1247,10 +1247,10 @@ fn visit_block(&mut self, block: &mut P) { AstFragmentKind::Items, after_derive).make_items(); } - match item.node { + match item.kind { ast::ItemKind::Mac(..) => { self.check_attributes(&item.attrs); - item.and_then(|item| match item.node { + item.and_then(|item| match item.kind { ItemKind::Mac(mac) => self.collect( AstFragmentKind::Items, InvocationKind::Bang { mac, span: item.span } ).make_items(), diff --git a/src/libsyntax/ext/mbe/macro_rules.rs b/src/libsyntax/ext/mbe/macro_rules.rs index c24f6a66603..aec4a683141 100644 --- a/src/libsyntax/ext/mbe/macro_rules.rs +++ b/src/libsyntax/ext/mbe/macro_rules.rs @@ -302,7 +302,7 @@ pub fn compile_declarative_macro( let tt_spec = ast::Ident::new(sym::tt, def.span); // Parse the macro_rules! invocation - let body = match def.node { + let body = match def.kind { ast::ItemKind::MacroDef(ref body) => body, _ => unreachable!(), }; diff --git a/src/libsyntax/ext/placeholders.rs b/src/libsyntax/ext/placeholders.rs index cb4c685dabe..a06de0f5517 100644 --- a/src/libsyntax/ext/placeholders.rs +++ b/src/libsyntax/ext/placeholders.rs @@ -48,7 +48,7 @@ fn mac_placeholder() -> ast::Mac { AstFragmentKind::OptExpr => AstFragment::OptExpr(Some(expr_placeholder())), AstFragmentKind::Items => AstFragment::Items(smallvec![P(ast::Item { id, span, ident, vis, attrs, - node: ast::ItemKind::Mac(mac_placeholder()), + kind: ast::ItemKind::Mac(mac_placeholder()), tokens: None, })]), AstFragmentKind::TraitItems => AstFragment::TraitItems(smallvec![ast::TraitItem { @@ -251,7 +251,7 @@ fn flat_map_generic_param( } fn flat_map_item(&mut self, item: P) -> SmallVec<[P; 1]> { - match item.node { + match item.kind { ast::ItemKind::Mac(_) => return self.remove(item.id).make_items(), ast::ItemKind::MacroDef(_) => return smallvec![item], _ => {} @@ -337,7 +337,7 @@ fn visit_block(&mut self, block: &mut P) { fn visit_mod(&mut self, module: &mut ast::Mod) { noop_visit_mod(module, self); - module.items.retain(|item| match item.node { + module.items.retain(|item| match item.kind { ast::ItemKind::Mac(_) if !self.cx.ecfg.keep_macs => false, // remove macro definitions _ => true, }); diff --git a/src/libsyntax/ext/proc_macro.rs b/src/libsyntax/ext/proc_macro.rs index 47b17ced816..e17bbf79fd5 100644 --- a/src/libsyntax/ext/proc_macro.rs +++ b/src/libsyntax/ext/proc_macro.rs @@ -107,7 +107,7 @@ fn expand(&self, return Vec::new() } }; - match item.node { + match item.kind { ItemKind::Struct(..) | ItemKind::Enum(..) | ItemKind::Union(..) => {}, diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs index 1729ae7eae8..2ed4404fb3c 100644 --- a/src/libsyntax/feature_gate/check.rs +++ b/src/libsyntax/feature_gate/check.rs @@ -302,7 +302,7 @@ fn visit_name(&mut self, sp: Span, name: ast::Name) { } fn visit_item(&mut self, i: &'a ast::Item) { - match i.node { + match i.kind { ast::ItemKind::ForeignMod(ref foreign_module) => { self.check_abi(foreign_module.abi, i.span); } diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index 0a42fc0cdfd..c448aa980c6 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -994,7 +994,7 @@ pub fn noop_visit_crate(krate: &mut Crate, vis: &mut T) { id: DUMMY_NODE_ID, vis: respan(span.shrink_to_lo(), VisibilityKind::Public), span, - node: ItemKind::Mod(module), + kind: ItemKind::Mod(module), tokens: None, }); let items = vis.flat_map_item(item); @@ -1004,8 +1004,8 @@ pub fn noop_visit_crate(krate: &mut Crate, vis: &mut T) { let module = Mod { inner: span, items: vec![], inline: true }; Crate { module, attrs: vec![], span } } else if len == 1 { - let Item { attrs, span, node, .. } = items.into_iter().next().unwrap().into_inner(); - match node { + let Item { attrs, span, kind, .. } = items.into_iter().next().unwrap().into_inner(); + match kind { ItemKind::Mod(module) => Crate { module, attrs, span }, _ => panic!("visitor converted a module to not a module"), } @@ -1018,11 +1018,11 @@ pub fn noop_visit_crate(krate: &mut Crate, vis: &mut T) { // Mutates one item into possibly many items. pub fn noop_flat_map_item(mut item: P, visitor: &mut T) -> SmallVec<[P; 1]> { - let Item { ident, attrs, id, node, vis, span, tokens: _ } = item.deref_mut(); + let Item { ident, attrs, id, kind, vis, span, tokens: _ } = item.deref_mut(); visitor.visit_ident(ident); visit_attrs(attrs, visitor); visitor.visit_id(id); - visitor.visit_item_kind(node); + visitor.visit_item_kind(kind); visitor.visit_vis(vis); visitor.visit_span(span); diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs index 62cb836e31e..ec5d00e0952 100644 --- a/src/libsyntax/parse/diagnostics.rs +++ b/src/libsyntax/parse/diagnostics.rs @@ -761,7 +761,7 @@ pub fn maybe_annotate_with_ascription( ); if !items.is_empty() { let previous_item = &items[items.len() - 1]; - let previous_item_kind_name = match previous_item.node { + let previous_item_kind_name = match previous_item.kind { // Say "braced struct" because tuple-structs and // braceless-empty-struct declarations do take a semicolon. ItemKind::Struct(..) => Some("braced struct"), diff --git a/src/libsyntax/parse/parser/item.rs b/src/libsyntax/parse/parser/item.rs index 27b0325db12..83721a2866a 100644 --- a/src/libsyntax/parse/parser/item.rs +++ b/src/libsyntax/parse/parser/item.rs @@ -1949,13 +1949,13 @@ fn complain_if_pub_macro(&self, vis: &VisibilityKind, sp: Span) { } } - fn mk_item(&self, span: Span, ident: Ident, node: ItemKind, vis: Visibility, + fn mk_item(&self, span: Span, ident: Ident, kind: ItemKind, vis: Visibility, attrs: Vec) -> P { P(Item { ident, attrs, id: DUMMY_NODE_ID, - node, + kind, vis, span, tokens: None, diff --git a/src/libsyntax/parse/tests.rs b/src/libsyntax/parse/tests.rs index 7b714858850..3bdb9227b4e 100644 --- a/src/libsyntax/parse/tests.rs +++ b/src/libsyntax/parse/tests.rs @@ -299,7 +299,7 @@ fn out_of_line_mod() { &sess, ).unwrap().unwrap(); - if let ast::ItemKind::Mod(ref m) = item.node { + if let ast::ItemKind::Mod(ref m) = item.kind { assert!(m.items.len() == 2); } else { panic!(); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 5bf5842e3f7..675490552e5 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1142,7 +1142,7 @@ fn print_associated_type(&mut self, self.maybe_print_comment(item.span.lo()); self.print_outer_attributes(&item.attrs); self.ann.pre(self, AnnNode::Item(item)); - match item.node { + match item.kind { ast::ItemKind::ExternCrate(orig_name) => { self.head(visibility_qualified(&item.vis, "extern crate")); if let Some(orig_name) = orig_name { diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 477852e5df1..ea6d27d4f29 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -230,7 +230,7 @@ pub fn walk_trait_ref<'a, V: Visitor<'a>>(visitor: &mut V, trait_ref: &'a TraitR pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) { visitor.visit_vis(&item.vis); visitor.visit_ident(item.ident); - match item.node { + match item.kind { ItemKind::ExternCrate(orig_name) => { if let Some(orig_name) = orig_name { visitor.visit_name(item.span, orig_name); diff --git a/src/libsyntax_ext/deriving/clone.rs b/src/libsyntax_ext/deriving/clone.rs index 9a4c540dc6f..9ef2c033b07 100644 --- a/src/libsyntax_ext/deriving/clone.rs +++ b/src/libsyntax_ext/deriving/clone.rs @@ -32,7 +32,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt<'_>, let is_shallow; match *item { Annotatable::Item(ref annitem) => { - match annitem.node { + match annitem.kind { ItemKind::Struct(_, Generics { ref params, .. }) | ItemKind::Enum(_, Generics { ref params, .. }) => { let container_id = cx.current_expansion.id.expn_data().parent; diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index b4306a1fd16..9f75f72e820 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -409,7 +409,7 @@ pub fn expand_ext(self, } false }); - let has_no_type_params = match item.node { + let has_no_type_params = match item.kind { ast::ItemKind::Struct(_, ref generics) | ast::ItemKind::Enum(_, ref generics) | ast::ItemKind::Union(_, ref generics) => { @@ -431,7 +431,7 @@ pub fn expand_ext(self, has_no_type_params; let use_temporaries = is_packed && is_always_copy; - let newitem = match item.node { + let newitem = match item.kind { ast::ItemKind::Struct(ref struct_def, ref generics) => { self.expand_struct_def(cx, &struct_def, item.ident, generics, from_scratch, use_temporaries) @@ -1780,7 +1780,7 @@ pub fn cs_fold1(use_foldl: bool, /// (for an enum, no variant has any fields) pub fn is_type_without_fields(item: &Annotatable) -> bool { if let Annotatable::Item(ref item) = *item { - match item.node { + match item.kind { ast::ItemKind::Enum(ref enum_def, _) => { enum_def.variants.iter().all(|v| v.data.fields().is_empty()) } diff --git a/src/libsyntax_ext/global_allocator.rs b/src/libsyntax_ext/global_allocator.rs index 19a87e6dc6d..cd2a9b61a76 100644 --- a/src/libsyntax_ext/global_allocator.rs +++ b/src/libsyntax_ext/global_allocator.rs @@ -20,7 +20,7 @@ pub fn expand( vec![item] }; let item = match item { - Annotatable::Item(item) => match item.node { + Annotatable::Item(item) => match item.kind { ItemKind::Static(..) => item, _ => return not_static(Annotatable::Item(item)), } diff --git a/src/libsyntax_ext/global_asm.rs b/src/libsyntax_ext/global_asm.rs index c56b3f3fc80..72fb5b47c21 100644 --- a/src/libsyntax_ext/global_asm.rs +++ b/src/libsyntax_ext/global_asm.rs @@ -28,7 +28,7 @@ pub fn expand_global_asm<'cx>(cx: &'cx mut ExtCtxt<'_>, ident: ast::Ident::invalid(), attrs: Vec::new(), id: ast::DUMMY_NODE_ID, - node: ast::ItemKind::GlobalAsm(P(global_asm)), + kind: ast::ItemKind::GlobalAsm(P(global_asm)), vis: respan(sp.shrink_to_lo(), ast::VisibilityKind::Inherited), span: cx.with_def_site_ctxt(sp), tokens: None, diff --git a/src/libsyntax_ext/plugin_macro_defs.rs b/src/libsyntax_ext/plugin_macro_defs.rs index ccdc5bd81a0..315babceae3 100644 --- a/src/libsyntax_ext/plugin_macro_defs.rs +++ b/src/libsyntax_ext/plugin_macro_defs.rs @@ -28,7 +28,7 @@ fn plugin_macro_def(name: Name, span: Span) -> P { ident: Ident::new(name, span), attrs: vec![rustc_builtin_macro], id: DUMMY_NODE_ID, - node: ItemKind::MacroDef(MacroDef { tokens: TokenStream::new(trees), legacy: true }), + kind: ItemKind::MacroDef(MacroDef { tokens: TokenStream::new(trees), legacy: true }), vis: respan(span, VisibilityKind::Inherited), span: span, tokens: None, diff --git a/src/libsyntax_ext/proc_macro_harness.rs b/src/libsyntax_ext/proc_macro_harness.rs index f33c813d86c..9b53bcb841c 100644 --- a/src/libsyntax_ext/proc_macro_harness.rs +++ b/src/libsyntax_ext/proc_macro_harness.rs @@ -226,7 +226,7 @@ fn collect_bang_proc_macro(&mut self, item: &'a ast::Item) { impl<'a> Visitor<'a> for CollectProcMacros<'a> { fn visit_item(&mut self, item: &'a ast::Item) { - if let ast::ItemKind::MacroDef(..) = item.node { + if let ast::ItemKind::MacroDef(..) = item.kind { if self.is_proc_macro_crate && attr::contains_name(&item.attrs, sym::macro_export) { let msg = "cannot export macro_rules! macros from a `proc-macro` crate type currently"; @@ -238,7 +238,7 @@ fn visit_item(&mut self, item: &'a ast::Item) { // we're just not interested in this item. // // If we find one, try to locate a `#[proc_macro_derive]` attribute on it. - let is_fn = match item.node { + let is_fn = match item.kind { ast::ItemKind::Fn(..) => true, _ => false, }; diff --git a/src/libsyntax_ext/test.rs b/src/libsyntax_ext/test.rs index a5d5ceb4b4f..5d68a92579f 100644 --- a/src/libsyntax_ext/test.rs +++ b/src/libsyntax_ext/test.rs @@ -78,7 +78,7 @@ pub fn expand_test_or_bench( "`#[test]` attribute is only allowed on non associated functions").raise(); }; - if let ast::ItemKind::Mac(_) = item.node { + if let ast::ItemKind::Mac(_) = item.kind { cx.parse_sess.span_diagnostic.span_warn(item.span, "`#[test]` attribute should not be used on macros. Use `#[cfg(test)]` instead."); return vec![Annotatable::Item(item)]; @@ -264,7 +264,7 @@ fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic { fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { let has_should_panic_attr = attr::contains_name(&i.attrs, sym::should_panic); let ref sd = cx.parse_sess.span_diagnostic; - if let ast::ItemKind::Fn(ref decl, ref header, ref generics, _) = i.node { + if let ast::ItemKind::Fn(ref decl, ref header, ref generics, _) = i.kind { if header.unsafety == ast::Unsafety::Unsafe { sd.span_err( i.span, @@ -315,7 +315,7 @@ fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { } fn has_bench_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { - let has_sig = if let ast::ItemKind::Fn(ref decl, _, _, _) = i.node { + let has_sig = if let ast::ItemKind::Fn(ref decl, _, _, _) = i.kind { // N.B., inadequate check, but we're running // well before resolve, can't get too deep. decl.inputs.len() == 1 diff --git a/src/libsyntax_ext/test_harness.rs b/src/libsyntax_ext/test_harness.rs index 56de0c97f81..fc1daa7d9b2 100644 --- a/src/libsyntax_ext/test_harness.rs +++ b/src/libsyntax_ext/test_harness.rs @@ -85,7 +85,7 @@ fn visit_crate(&mut self, c: &mut ast::Crate) { // We don't want to recurse into anything other than mods, since // mods or tests inside of functions will break things - if let ast::ItemKind::Mod(mut module) = item.node { + if let ast::ItemKind::Mod(mut module) = item.kind { let tests = mem::take(&mut self.tests); noop_visit_mod(&mut module, self); let mut tests = mem::replace(&mut self.tests, tests); @@ -111,7 +111,7 @@ fn visit_crate(&mut self, c: &mut ast::Crate) { } self.cx.test_cases.extend(tests); } - item.node = ast::ItemKind::Mod(module); + item.kind = ast::ItemKind::Mod(module); } smallvec![P(item)] } @@ -142,7 +142,7 @@ impl MutVisitor for EntryPointCleaner { EntryPointType::MainNamed | EntryPointType::MainAttr | EntryPointType::Start => - item.map(|ast::Item {id, ident, attrs, node, vis, span, tokens}| { + item.map(|ast::Item {id, ident, attrs, kind, vis, span, tokens}| { let allow_ident = Ident::new(sym::allow, self.def_site); let dc_nested = attr::mk_nested_word_item( Ident::from_str_and_span("dead_code", self.def_site), @@ -159,7 +159,7 @@ impl MutVisitor for EntryPointCleaner { }) .chain(iter::once(allow_dead_code)) .collect(), - node, + kind, vis, span, tokens, @@ -295,7 +295,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P { ident: main_id, attrs: vec![main_attr], id: ast::DUMMY_NODE_ID, - node: main, + kind: main, vis: respan(sp, ast::VisibilityKind::Public), span: sp, tokens: None,