]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_typeck/collect.rs
Rename `Item.node` to `Item.kind`
[rust.git] / src / librustc_typeck / collect.rs
index 82d55e0df599b93887b2b0d3589cab2d66c4712a..28c275e2d75abeca5684bffd38bc0477e3180e14 100644 (file)
@@ -135,7 +135,7 @@ fn visit_generics(&mut self, generics: &'tcx hir::Generics) {
     }
 
     fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
-        if let hir::ExprKind::Closure(..) = expr.node {
+        if let hir::ExprKind::Closure(..) = expr.kind {
             let def_id = self.tcx.hir().local_def_id(expr.hir_id);
             self.tcx.generics_of(def_id);
             self.tcx.type_of(def_id);
@@ -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)
@@ -387,7 +387,7 @@ fn type_parameter_bounds_in_generics(
 /// `ast_ty_to_ty`, because we want to avoid triggering an all-out
 /// conversion of the type to avoid inducing unnecessary cycles.
 fn is_param(tcx: TyCtxt<'_>, ast_ty: &hir::Ty, param_id: hir::HirId) -> bool {
-    if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = ast_ty.node {
+    if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = ast_ty.kind {
         match path.res {
             Res::SelfTy(Some(def_id), None) | Res::Def(DefKind::TyParam, def_id) => {
                 def_id == tcx.hir().local_def_id(param_id)
@@ -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);
             }
         }
@@ -486,12 +486,12 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) {
     let def_id = tcx.hir().local_def_id(trait_item.hir_id);
     tcx.generics_of(def_id);
 
-    match trait_item.node {
+    match trait_item.kind {
         hir::TraitItemKind::Const(..)
         | hir::TraitItemKind::Type(_, Some(_))
         | hir::TraitItemKind::Method(..) => {
             tcx.type_of(def_id);
-            if let hir::TraitItemKind::Method(..) = trait_item.node {
+            if let hir::TraitItemKind::Method(..) = trait_item.kind {
                 tcx.fn_sig(def_id);
             }
         }
@@ -507,7 +507,7 @@ fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::HirId) {
     tcx.generics_of(def_id);
     tcx.type_of(def_id);
     tcx.predicates_of(def_id);
-    if let hir::ImplItemKind::Method(..) = tcx.hir().expect_impl_item(impl_item_id).node {
+    if let hir::ImplItemKind::Method(..) = tcx.hir().expect_impl_item(impl_item_id).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"),
@@ -796,7 +796,7 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
             if self.has_late_bound_regions.is_some() {
                 return;
             }
-            match ty.node {
+            match ty.kind {
                 hir::TyKind::BareFn(..) => {
                     self.outer_index.shift_in(1);
                     intravisit::walk_ty(self, ty);
@@ -860,13 +860,13 @@ fn has_late_bound_regions<'tcx>(
     }
 
     match node {
-        Node::TraitItem(item) => match item.node {
+        Node::TraitItem(item) => match item.kind {
             hir::TraitItemKind::Method(ref sig, _) => {
                 has_late_bound_regions(tcx, &item.generics, &sig.decl)
             }
             _ => None,
         },
-        Node::ImplItem(item) => match item.node {
+        Node::ImplItem(item) => match item.kind {
             hir::ImplItemKind::Method(ref sig, _) => {
                 has_late_bound_regions(tcx, &item.generics, &sig.decl)
             }
@@ -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)
             }
@@ -915,10 +915,10 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
             }
         }
         Node::Expr(&hir::Expr {
-            node: hir::ExprKind::Closure(..),
+            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
                 }
@@ -1072,7 +1072,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
     // cares about anything but the length is instantiation,
     // and we don't do that for closures.
     if let Node::Expr(&hir::Expr {
-        node: hir::ExprKind::Closure(.., gen),
+        kind: hir::ExprKind::Closure(.., gen),
         ..
     }) = node
     {
@@ -1207,14 +1207,14 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
     let icx = ItemCtxt::new(tcx, def_id);
 
     Some(match tcx.hir().get(hir_id) {
-        Node::TraitItem(item) => match item.node {
+        Node::TraitItem(item) => match item.kind {
             TraitItemKind::Method(..) => {
                 let substs = InternalSubsts::identity_for_item(tcx, def_id);
                 tcx.mk_fn_def(def_id, substs)
             }
             TraitItemKind::Const(ref ty, body_id)  => {
                 body_id.and_then(|body_id| {
-                    if let hir::TyKind::Infer = ty.node {
+                    if let hir::TyKind::Infer = ty.kind {
                         Some(infer_placeholder_type(tcx, def_id, body_id, ty.span, item.ident))
                     } else {
                         None
@@ -1230,13 +1230,13 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
             }
         },
 
-        Node::ImplItem(item) => match item.node {
+        Node::ImplItem(item) => match item.kind {
             ImplItemKind::Method(..) => {
                 let substs = InternalSubsts::identity_for_item(tcx, def_id);
                 tcx.mk_fn_def(def_id, substs)
             }
             ImplItemKind::Const(ref ty, body_id) => {
-                if let hir::TyKind::Infer = ty.node {
+                if let hir::TyKind::Infer = ty.kind {
                     infer_placeholder_type(tcx, def_id, body_id, ty.span, item.ident)
                 } else {
                     icx.to_ty(ty)
@@ -1265,10 +1265,10 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
         },
 
         Node::Item(item) => {
-            match item.node {
+            match item.kind {
                 ItemKind::Static(ref ty, .., body_id)
                 | ItemKind::Const(ref ty, body_id) => {
-                    if let hir::TyKind::Infer = ty.node {
+                    if let hir::TyKind::Infer = ty.kind {
                         infer_placeholder_type(tcx, def_id, body_id, ty.span, item.ident)
                     } else {
                         icx.to_ty(ty)
@@ -1325,7 +1325,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
                     span_bug!(
                         item.span,
                         "compute_type_of_item: unexpected item type: {:?}",
-                        item.node
+                        item.kind
                     );
                 }
             }
@@ -1355,7 +1355,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
         Node::Field(field) => icx.to_ty(&field.ty),
 
         Node::Expr(&hir::Expr {
-            node: hir::ExprKind::Closure(.., gen),
+            kind: hir::ExprKind::Closure(.., gen),
             ..
         }) => {
             if gen.is_some() {
@@ -1373,15 +1373,15 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
             let parent_node = tcx.hir().get(tcx.hir().get_parent_node(hir_id));
             match parent_node {
                 Node::Ty(&hir::Ty {
-                    node: hir::TyKind::Array(_, ref constant),
+                    kind: hir::TyKind::Array(_, ref constant),
                     ..
                 })
                 | Node::Ty(&hir::Ty {
-                    node: hir::TyKind::Typeof(ref constant),
+                    kind: hir::TyKind::Typeof(ref constant),
                     ..
                 })
                 | Node::Expr(&hir::Expr {
-                    node: ExprKind::Repeat(_, ref constant),
+                    kind: ExprKind::Repeat(_, ref constant),
                     ..
                 }) if constant.hir_id == hir_id =>
                 {
@@ -1399,22 +1399,22 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
                         .to_ty(tcx)
                 }
 
-                Node::Ty(&hir::Ty { node: hir::TyKind::Path(_), .. }) |
-                Node::Expr(&hir::Expr { node: ExprKind::Struct(..), .. }) |
-                Node::Expr(&hir::Expr { node: ExprKind::Path(_), .. }) |
+                Node::Ty(&hir::Ty { kind: hir::TyKind::Path(_), .. }) |
+                Node::Expr(&hir::Expr { kind: ExprKind::Struct(..), .. }) |
+                Node::Expr(&hir::Expr { kind: ExprKind::Path(_), .. }) |
                 Node::TraitRef(..) => {
                     let path = match parent_node {
                         Node::Ty(&hir::Ty {
-                            node: hir::TyKind::Path(QPath::Resolved(_, ref path)),
+                            kind: hir::TyKind::Path(QPath::Resolved(_, ref path)),
                             ..
                         })
                         | Node::Expr(&hir::Expr {
-                            node: ExprKind::Path(QPath::Resolved(_, ref path)),
+                            kind: ExprKind::Path(QPath::Resolved(_, ref path)),
                             ..
                         }) => {
                             Some(&**path)
                         }
-                        Node::Expr(&hir::Expr { node: ExprKind::Struct(ref path, ..), .. }) => {
+                        Node::Expr(&hir::Expr { kind: ExprKind::Struct(ref path, ..), .. }) => {
                             if let QPath::Resolved(_, ref path) = **path {
                                 Some(&**path)
                             } else {
@@ -1769,7 +1769,7 @@ fn visit_trait_item(&mut self, it: &'tcx TraitItem) {
 
 pub fn get_infer_ret_ty(output: &'_ hir::FunctionRetTy) -> Option<&hir::Ty> {
     if let hir::FunctionRetTy::Return(ref ty) = output {
-        if let hir::TyKind::Infer = ty.node {
+        if let hir::TyKind::Infer = ty.kind {
             return Some(&**ty)
         }
     }
@@ -1786,15 +1786,15 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
 
     match tcx.hir().get(hir_id) {
         TraitItem(hir::TraitItem {
-            node: TraitItemKind::Method(MethodSig { header, decl }, TraitMethod::Provided(_)),
+            kind: TraitItemKind::Method(MethodSig { header, decl }, TraitMethod::Provided(_)),
             ..
         })
         | ImplItem(hir::ImplItem {
-            node: ImplItemKind::Method(MethodSig { header, decl }, _),
+            kind: ImplItemKind::Method(MethodSig { header, decl }, _),
             ..
         })
         | Item(hir::Item {
-            node: ItemKind::Fn(decl, header, _, _),
+            kind: ItemKind::Fn(decl, header, _, _),
             ..
         }) => match get_infer_ret_ty(&decl.output) {
             Some(ty) => {
@@ -1816,7 +1816,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
         },
 
         TraitItem(hir::TraitItem {
-            node: TraitItemKind::Method(MethodSig { header, decl }, _),
+            kind: TraitItemKind::Method(MethodSig { header, decl }, _),
             ..
         }) => {
             AstConv::ty_of_fn(&icx, header.unsafety, header.abi, decl)
@@ -1847,7 +1847,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
         }
 
         Expr(&hir::Expr {
-            node: hir::ExprKind::Closure(..),
+            kind: hir::ExprKind::Closure(..),
             ..
         }) => {
             // Closure signatures are not like other function
@@ -1878,7 +1878,7 @@ fn impl_trait_ref(tcx: TyCtxt<'_>, def_id: DefId) -> Option<ty::TraitRef<'_>> {
     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");
@@ -2055,7 +2055,7 @@ fn extend<I: IntoIterator<Item = (ty::Predicate<'tcx>, Span)>>(&mut self, iter:
     let ast_generics = match node {
         Node::TraitItem(item) => &item.generics,
 
-        Node::ImplItem(item) => match item.node {
+        Node::ImplItem(item) => match item.kind {
             ImplItemKind::OpaqueTy(ref bounds) => {
                 let substs = InternalSubsts::identity_for_item(tcx, def_id);
                 let opaque_ty = tcx.mk_opaque(def_id, substs);
@@ -2076,7 +2076,7 @@ fn extend<I: IntoIterator<Item = (ty::Predicate<'tcx>, 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);
@@ -2281,7 +2281,7 @@ fn extend<I: IntoIterator<Item = (ty::Predicate<'tcx>, Span)>>(&mut self, iter:
     if let Some((self_trait_ref, trait_items)) = is_trait {
         predicates.extend(trait_items.iter().flat_map(|trait_item_ref| {
             let trait_item = tcx.hir().trait_item(trait_item_ref.id);
-            let bounds = match trait_item.node {
+            let bounds = match trait_item.kind {
                 hir::TraitItemKind::Type(ref bounds, _) => bounds,
                 _ => return Vec::new().into_iter()
             };
@@ -2310,7 +2310,7 @@ fn extend<I: IntoIterator<Item = (ty::Predicate<'tcx>, 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<hir::Mutability> {
     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), ..