]> git.lizzy.rs Git - rust.git/commitdiff
Remove `ast::{Impl,Trait}{Item,ItemKind}`.
authorMazdak Farrokhzad <twingoow@gmail.com>
Sat, 7 Dec 2019 23:08:09 +0000 (00:08 +0100)
committerMazdak Farrokhzad <twingoow@gmail.com>
Thu, 12 Dec 2019 17:05:05 +0000 (18:05 +0100)
19 files changed:
src/librustc/hir/lowering.rs
src/librustc/hir/lowering/item.rs
src/librustc/lint/context.rs
src/librustc/lint/mod.rs
src/librustc_interface/util.rs
src/librustc_lint/builtin.rs
src/librustc_passes/ast_validation.rs
src/librustc_passes/hir_stats.rs
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/def_collector.rs
src/librustc_resolve/late.rs
src/librustc_save_analysis/dump_visitor.rs
src/libsyntax/ast.rs
src/libsyntax/feature_gate/check.rs
src/libsyntax/token.rs
src/libsyntax_expand/base.rs
src/libsyntax_expand/expand.rs
src/libsyntax_expand/placeholders.rs
src/libsyntax_ext/deriving/generic/mod.rs

index 58225e87f2682bb80f42487bd01e4e5aeda28633..78df14adc5d6d3a90d22e657878ec883cc41e952 100644 (file)
@@ -477,11 +477,11 @@ fn visit_item(&mut self, item: &'tcx Item) {
                 });
             }
 
-            fn visit_trait_item(&mut self, item: &'tcx TraitItem) {
+            fn visit_trait_item(&mut self, item: &'tcx AssocItem) {
                 self.lctx.allocate_hir_id_counter(item.id);
 
                 match item.kind {
-                    TraitItemKind::Method(_, None) => {
+                    AssocItemKind::Method(_, None) => {
                         // Ignore patterns in trait methods without bodies
                         self.with_hir_id_owner(None, |this| {
                             visit::walk_trait_item(this, item)
@@ -493,7 +493,7 @@ fn visit_trait_item(&mut self, item: &'tcx TraitItem) {
                 }
             }
 
-            fn visit_impl_item(&mut self, item: &'tcx ImplItem) {
+            fn visit_impl_item(&mut self, item: &'tcx AssocItem) {
                 self.lctx.allocate_hir_id_counter(item.id);
                 self.with_hir_id_owner(Some(item.id), |this| {
                     visit::walk_impl_item(this, item);
index c3d2ed6b39cd21cf3cc86be650b7b77b91a4b2a7..f25714f741b8da45737b66d3ce89612738904cfe 100644 (file)
@@ -86,7 +86,7 @@ fn visit_item(&mut self, item: &'tcx Item) {
         }
     }
 
-    fn visit_trait_item(&mut self, item: &'tcx TraitItem) {
+    fn visit_trait_item(&mut self, item: &'tcx AssocItem) {
         self.lctx.with_hir_id_owner(item.id, |lctx| {
             let hir_item = lctx.lower_trait_item(item);
             let id = hir::TraitItemId { hir_id: hir_item.hir_id };
@@ -97,7 +97,7 @@ fn visit_trait_item(&mut self, item: &'tcx TraitItem) {
         visit::walk_assoc_item(self, item);
     }
 
-    fn visit_impl_item(&mut self, item: &'tcx ImplItem) {
+    fn visit_impl_item(&mut self, item: &'tcx AssocItem) {
         self.lctx.with_hir_id_owner(item.id, |lctx| {
             let hir_item = lctx.lower_impl_item(item);
             let id = hir::ImplItemId { hir_id: hir_item.hir_id };
@@ -813,11 +813,11 @@ fn lower_struct_field(&mut self, (index, f): (usize, &StructField)) -> hir::Stru
         }
     }
 
-    fn lower_trait_item(&mut self, i: &TraitItem) -> hir::TraitItem {
+    fn lower_trait_item(&mut self, i: &AssocItem) -> hir::TraitItem {
         let trait_item_def_id = self.resolver.definitions().local_def_id(i.id);
 
         let (generics, kind) = match i.kind {
-            TraitItemKind::Const(ref ty, ref default) => (
+            AssocItemKind::Const(ref ty, ref default) => (
                 self.lower_generics(&i.generics, ImplTraitContext::disallowed()),
                 hir::TraitItemKind::Const(
                     self.lower_ty(ty, ImplTraitContext::disallowed()),
@@ -826,7 +826,7 @@ fn lower_trait_item(&mut self, i: &TraitItem) -> hir::TraitItem {
                         .map(|x| self.lower_const_body(i.span, Some(x))),
                 ),
             ),
-            TraitItemKind::Method(ref sig, None) => {
+            AssocItemKind::Method(ref sig, None) => {
                 let names = self.lower_fn_params_to_names(&sig.decl);
                 let (generics, sig) = self.lower_method_sig(
                     &i.generics,
@@ -837,7 +837,7 @@ fn lower_trait_item(&mut self, i: &TraitItem) -> hir::TraitItem {
                 );
                 (generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Required(names)))
             }
-            TraitItemKind::Method(ref sig, Some(ref body)) => {
+            AssocItemKind::Method(ref sig, Some(ref body)) => {
                 let body_id = self.lower_fn_body_block(i.span, &sig.decl, Some(body));
                 let (generics, sig) = self.lower_method_sig(
                     &i.generics,
@@ -848,7 +848,7 @@ fn lower_trait_item(&mut self, i: &TraitItem) -> hir::TraitItem {
                 );
                 (generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Provided(body_id)))
             }
-            TraitItemKind::TyAlias(ref bounds, ref default) => {
+            AssocItemKind::TyAlias(ref bounds, ref default) => {
                 let generics = self.lower_generics(&i.generics, ImplTraitContext::disallowed());
                 let kind = hir::TraitItemKind::Type(
                     self.lower_param_bounds(bounds, ImplTraitContext::disallowed()),
@@ -859,7 +859,7 @@ fn lower_trait_item(&mut self, i: &TraitItem) -> hir::TraitItem {
 
                 (generics, kind)
             },
-            TraitItemKind::Macro(..) => bug!("macro item shouldn't exist at this point"),
+            AssocItemKind::Macro(..) => bug!("macro item shouldn't exist at this point"),
         };
 
         hir::TraitItem {
@@ -872,21 +872,21 @@ fn lower_trait_item(&mut self, i: &TraitItem) -> hir::TraitItem {
         }
     }
 
-    fn lower_trait_item_ref(&mut self, i: &TraitItem) -> hir::TraitItemRef {
+    fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemRef {
         let (kind, has_default) = match i.kind {
-            TraitItemKind::Const(_, ref default) => {
+            AssocItemKind::Const(_, ref default) => {
                 (hir::AssocItemKind::Const, default.is_some())
             }
-            TraitItemKind::TyAlias(_, ref default) => {
+            AssocItemKind::TyAlias(_, ref default) => {
                 (hir::AssocItemKind::Type, default.is_some())
             }
-            TraitItemKind::Method(ref sig, ref default) => (
+            AssocItemKind::Method(ref sig, ref default) => (
                 hir::AssocItemKind::Method {
                     has_self: sig.decl.has_self(),
                 },
                 default.is_some(),
             ),
-            TraitItemKind::Macro(..) => unimplemented!(),
+            AssocItemKind::Macro(..) => unimplemented!(),
         };
         hir::TraitItemRef {
             id: hir::TraitItemId { hir_id: self.lower_node_id(i.id) },
@@ -902,18 +902,18 @@ fn expr_err(&mut self, span: Span) -> hir::Expr {
         self.expr(span, hir::ExprKind::Err, ThinVec::new())
     }
 
-    fn lower_impl_item(&mut self, i: &ImplItem) -> hir::ImplItem {
+    fn lower_impl_item(&mut self, i: &AssocItem) -> hir::ImplItem {
         let impl_item_def_id = self.resolver.definitions().local_def_id(i.id);
 
         let (generics, kind) = match i.kind {
-            ImplItemKind::Const(ref ty, ref expr) => (
+            AssocItemKind::Const(ref ty, ref expr) => (
                 self.lower_generics(&i.generics, ImplTraitContext::disallowed()),
                 hir::ImplItemKind::Const(
                     self.lower_ty(ty, ImplTraitContext::disallowed()),
                     self.lower_const_body(i.span, expr.as_deref()),
                 ),
             ),
-            ImplItemKind::Method(ref sig, ref body) => {
+            AssocItemKind::Method(ref sig, ref body) => {
                 self.current_item = Some(i.span);
                 let body_id = self.lower_maybe_async_body(
                     i.span,
@@ -932,7 +932,7 @@ fn lower_impl_item(&mut self, i: &ImplItem) -> hir::ImplItem {
 
                 (generics, hir::ImplItemKind::Method(sig, body_id))
             }
-            ImplItemKind::TyAlias(_, ref ty) => {
+            AssocItemKind::TyAlias(_, ref ty) => {
                 let generics = self.lower_generics(&i.generics, ImplTraitContext::disallowed());
                 let kind = match ty {
                     None => {
@@ -951,7 +951,7 @@ fn lower_impl_item(&mut self, i: &ImplItem) -> hir::ImplItem {
                 };
                 (generics, kind)
             },
-            ImplItemKind::Macro(..) => bug!("`TyMac` should have been expanded by now"),
+            AssocItemKind::Macro(..) => bug!("`TyMac` should have been expanded by now"),
         };
 
         hir::ImplItem {
@@ -968,7 +968,7 @@ fn lower_impl_item(&mut self, i: &ImplItem) -> hir::ImplItem {
         // [1] since `default impl` is not yet implemented, this is always true in impls
     }
 
-    fn lower_impl_item_ref(&mut self, i: &ImplItem) -> hir::ImplItemRef {
+    fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemRef {
         hir::ImplItemRef {
             id: hir::ImplItemId { hir_id: self.lower_node_id(i.id) },
             ident: i.ident,
@@ -976,18 +976,18 @@ fn lower_impl_item_ref(&mut self, i: &ImplItem) -> hir::ImplItemRef {
             vis: self.lower_visibility(&i.vis, Some(i.id)),
             defaultness: self.lower_defaultness(i.defaultness, true /* [1] */),
             kind: match &i.kind {
-                ImplItemKind::Const(..) => hir::AssocItemKind::Const,
-                ImplItemKind::TyAlias(_, ty) => match ty
+                AssocItemKind::Const(..) => hir::AssocItemKind::Const,
+                AssocItemKind::TyAlias(_, ty) => match ty
                     .as_deref()
                     .and_then(|ty| ty.kind.opaque_top_hack())
                 {
                     None => hir::AssocItemKind::Type,
                     Some(_) => hir::AssocItemKind::OpaqueTy,
                 },
-                ImplItemKind::Method(sig, _) => hir::AssocItemKind::Method {
+                AssocItemKind::Method(sig, _) => hir::AssocItemKind::Method {
                     has_self: sig.decl.has_self(),
                 },
-                ImplItemKind::Macro(..) => unimplemented!(),
+                AssocItemKind::Macro(..) => unimplemented!(),
             },
         }
 
index 7f72154e42c61eb0f7fcb447d12e04a295a4c33a..0fdd509a0bbec6c79b87977e5cad5b639bf9e12c 100644 (file)
@@ -1249,7 +1249,7 @@ fn visit_poly_trait_ref(&mut self, t: &'a ast::PolyTraitRef, m: &'a ast::TraitBo
         ast_visit::walk_poly_trait_ref(self, t, m);
     }
 
-    fn visit_trait_item(&mut self, trait_item: &'a ast::TraitItem) {
+    fn visit_trait_item(&mut self, trait_item: &'a ast::AssocItem) {
         self.with_lint_attrs(trait_item.id, &trait_item.attrs, |cx| {
             run_early_pass!(cx, check_trait_item, trait_item);
             ast_visit::walk_trait_item(cx, trait_item);
@@ -1257,7 +1257,7 @@ fn visit_trait_item(&mut self, trait_item: &'a ast::TraitItem) {
         });
     }
 
-    fn visit_impl_item(&mut self, impl_item: &'a ast::ImplItem) {
+    fn visit_impl_item(&mut self, impl_item: &'a ast::AssocItem) {
         self.with_lint_attrs(impl_item.id, &impl_item.attrs, |cx| {
             run_early_pass!(cx, check_impl_item, impl_item);
             ast_visit::walk_impl_item(cx, impl_item);
index a8d886866795eef22f1760bc105d0d53fdaa0eb5..0054f149f8c2753fde9ef532ddfd73c20a8d05c3 100644 (file)
@@ -258,10 +258,10 @@ fn check_fn_post(
                 c: Span,
                 d: ast::NodeId
             );
-            fn check_trait_item(a: &ast::TraitItem);
-            fn check_trait_item_post(a: &ast::TraitItem);
-            fn check_impl_item(a: &ast::ImplItem);
-            fn check_impl_item_post(a: &ast::ImplItem);
+            fn check_trait_item(a: &ast::AssocItem);
+            fn check_trait_item_post(a: &ast::AssocItem);
+            fn check_impl_item(a: &ast::AssocItem);
+            fn check_impl_item_post(a: &ast::AssocItem);
             fn check_struct_def(a: &ast::VariantData);
             fn check_struct_def_post(a: &ast::VariantData);
             fn check_struct_field(a: &ast::StructField);
index 026cb6eab1c7df08f14e8dc5d2c9ecf9ad9c5bde..da8eae6028e36070c1a8bd3030d67a8b09a23ab4 100644 (file)
@@ -776,22 +776,17 @@ fn visit_item_kind(&mut self, i: &mut ast::ItemKind) {
         self.run(is_const, |s| noop_visit_item_kind(i, s))
     }
 
-    fn flat_map_trait_item(&mut self, i: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> {
+    fn flat_map_trait_item(&mut self, i: ast::AssocItem) -> SmallVec<[ast::AssocItem; 1]> {
         let is_const = match i.kind {
-            ast::TraitItemKind::Const(..) => true,
-            ast::TraitItemKind::Method(ref sig, _) => Self::is_sig_const(sig),
+            ast::AssocItemKind::Const(..) => true,
+            ast::AssocItemKind::Method(ref sig, _) => Self::is_sig_const(sig),
             _ => false,
         };
         self.run(is_const, |s| noop_flat_map_assoc_item(i, s))
     }
 
-    fn flat_map_impl_item(&mut self, i: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> {
-        let is_const = match i.kind {
-            ast::ImplItemKind::Const(..) => true,
-            ast::ImplItemKind::Method(ref sig, _) => Self::is_sig_const(sig),
-            _ => false,
-        };
-        self.run(is_const, |s| noop_flat_map_assoc_item(i, s))
+    fn flat_map_impl_item(&mut self, i: ast::AssocItem) -> SmallVec<[ast::AssocItem; 1]> {
+        self.flat_map_trait_item(i)
     }
 
     fn visit_anon_const(&mut self, c: &mut ast::AnonConst) {
index 10b00d35d9bcaa9d0e12bf19ef2eee101d311770..8916fc088387156d4b36b49df8ffcaea17bf66d0 100644 (file)
@@ -268,8 +268,8 @@ fn check_fn(&mut self,
         }
     }
 
-    fn check_trait_item(&mut self, cx: &EarlyContext<'_>, item: &ast::TraitItem) {
-        if let ast::TraitItemKind::Method(ref sig, None) = item.kind {
+    fn check_trait_item(&mut self, cx: &EarlyContext<'_>, item: &ast::AssocItem) {
+        if let ast::AssocItemKind::Method(ref sig, None) = item.kind {
             if sig.header.unsafety == ast::Unsafety::Unsafe {
                 self.report_unsafe(cx, item.span, "declaration of an `unsafe` method")
             }
@@ -615,9 +615,9 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
 );
 
 impl EarlyLintPass for AnonymousParameters {
-    fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::TraitItem) {
+    fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::AssocItem) {
         match it.kind {
-            ast::TraitItemKind::Method(ref sig, _) => {
+            ast::AssocItemKind::Method(ref sig, _) => {
                 for arg in sig.decl.inputs.iter() {
                     match arg.pat.kind {
                         ast::PatKind::Ident(_, ident, None) => {
index c75bd996e10c1cfea867fd1dd831dfef9f22635f..609885cb254b77ae565967b95a5ebae7b558c738 100644 (file)
@@ -544,7 +544,7 @@ fn visit_item(&mut self, item: &'a Item) {
                 }
                 for impl_item in impl_items {
                     self.invalid_visibility(&impl_item.vis, None);
-                    if let ImplItemKind::Method(ref sig, _) = impl_item.kind {
+                    if let AssocItemKind::Method(ref sig, _) = impl_item.kind {
                         self.check_trait_fn_not_const(sig.header.constness);
                         self.check_trait_fn_not_async(impl_item.span, sig.header.asyncness.node);
                     }
index a5924efefc2af57db13ff21a4f8bf48d4a4929bf..66ceb4212c8aca9423e0a6505567420334613408 100644 (file)
@@ -314,12 +314,12 @@ fn visit_fn(&mut self,
         ast_visit::walk_fn(self, fk, fd, s)
     }
 
-    fn visit_trait_item(&mut self, ti: &'v ast::TraitItem) {
+    fn visit_trait_item(&mut self, ti: &'v ast::AssocItem) {
         self.record("TraitItem", Id::None, ti);
         ast_visit::walk_trait_item(self, ti)
     }
 
-    fn visit_impl_item(&mut self, ii: &'v ast::ImplItem) {
+    fn visit_impl_item(&mut self, ii: &'v ast::AssocItem) {
         self.record("ImplItem", Id::None, ii);
         ast_visit::walk_impl_item(self, ii)
     }
index d2d5a33ec7aa9d8912fe509d918a16265fd64e87..dc3013754404b39323a6e5ce6f9d9d80248d38e7 100644 (file)
@@ -30,7 +30,7 @@
 use syntax::ast::{Name, Ident};
 use syntax::attr;
 use syntax::ast::{self, Block, ForeignItem, ForeignItemKind, Item, ItemKind, NodeId};
-use syntax::ast::{MetaItemKind, StmtKind, TraitItem, TraitItemKind};
+use syntax::ast::{MetaItemKind, StmtKind, AssocItem, AssocItemKind};
 use syntax::token::{self, Token};
 use syntax::span_err;
 use syntax::source_map::{respan, Spanned};
@@ -1164,10 +1164,10 @@ fn visit_block(&mut self, block: &'b Block) {
         self.parent_scope.legacy = orig_current_legacy_scope;
     }
 
-    fn visit_trait_item(&mut self, item: &'b TraitItem) {
+    fn visit_trait_item(&mut self, item: &'b AssocItem) {
         let parent = self.parent_scope.module;
 
-        if let TraitItemKind::Macro(_) = item.kind {
+        if let AssocItemKind::Macro(_) = item.kind {
             self.visit_invoc(item.id);
             return
         }
@@ -1175,15 +1175,15 @@ fn visit_trait_item(&mut self, item: &'b TraitItem) {
         // Add the item to the trait info.
         let item_def_id = self.r.definitions.local_def_id(item.id);
         let (res, ns) = match item.kind {
-            TraitItemKind::Const(..) => (Res::Def(DefKind::AssocConst, item_def_id), ValueNS),
-            TraitItemKind::Method(ref sig, _) => {
+            AssocItemKind::Const(..) => (Res::Def(DefKind::AssocConst, item_def_id), ValueNS),
+            AssocItemKind::Method(ref sig, _) => {
                 if sig.decl.has_self() {
                     self.r.has_self.insert(item_def_id);
                 }
                 (Res::Def(DefKind::Method, item_def_id), ValueNS)
             }
-            TraitItemKind::TyAlias(..) => (Res::Def(DefKind::AssocTy, item_def_id), TypeNS),
-            TraitItemKind::Macro(_) => bug!(),  // handled above
+            AssocItemKind::TyAlias(..) => (Res::Def(DefKind::AssocTy, item_def_id), TypeNS),
+            AssocItemKind::Macro(_) => bug!(),  // handled above
         };
 
         let vis = ty::Visibility::Public;
@@ -1193,8 +1193,8 @@ fn visit_trait_item(&mut self, item: &'b TraitItem) {
         visit::walk_trait_item(self, item);
     }
 
-    fn visit_impl_item(&mut self, item: &'b ast::ImplItem) {
-        if let ast::ImplItemKind::Macro(..) = item.kind {
+    fn visit_impl_item(&mut self, item: &'b ast::AssocItem) {
+        if let ast::AssocItemKind::Macro(..) = item.kind {
             self.visit_invoc(item.id);
         } else {
             self.resolve_visibility(&item.vis);
index 471e2634b8acfd1765c175dab77069ae612ce4d7..6e26553d82f8262fe5e3272fd189d476f2e22d95 100644 (file)
@@ -212,23 +212,23 @@ fn visit_generic_param(&mut self, param: &'a GenericParam) {
         visit::walk_generic_param(self, param);
     }
 
-    fn visit_trait_item(&mut self, ti: &'a TraitItem) {
+    fn visit_trait_item(&mut self, ti: &'a AssocItem) {
         let def_data = match ti.kind {
-            TraitItemKind::Method(..) | TraitItemKind::Const(..) =>
+            AssocItemKind::Method(..) | AssocItemKind::Const(..) =>
                 DefPathData::ValueNs(ti.ident.name),
-            TraitItemKind::TyAlias(..) => {
+            AssocItemKind::TyAlias(..) => {
                 DefPathData::TypeNs(ti.ident.name)
             },
-            TraitItemKind::Macro(..) => return self.visit_macro_invoc(ti.id),
+            AssocItemKind::Macro(..) => return self.visit_macro_invoc(ti.id),
         };
 
         let def = self.create_def(ti.id, def_data, ti.span);
         self.with_parent(def, |this| visit::walk_trait_item(this, ti));
     }
 
-    fn visit_impl_item(&mut self, ii: &'a ImplItem) {
+    fn visit_impl_item(&mut self, ii: &'a AssocItem) {
         let def_data = match ii.kind {
-            ImplItemKind::Method(FnSig {
+            AssocItemKind::Method(FnSig {
                 ref header,
                 ref decl,
             }, ref body) if header.asyncness.node.is_async() => {
@@ -242,10 +242,10 @@ fn visit_impl_item(&mut self, ii: &'a ImplItem) {
                     body.as_deref(),
                 )
             }
-            ImplItemKind::Method(..) |
-            ImplItemKind::Const(..) => DefPathData::ValueNs(ii.ident.name),
-            ImplItemKind::TyAlias(..) => DefPathData::TypeNs(ii.ident.name),
-            ImplItemKind::Macro(..) => return self.visit_macro_invoc(ii.id),
+            AssocItemKind::Method(..) |
+            AssocItemKind::Const(..) => DefPathData::ValueNs(ii.ident.name),
+            AssocItemKind::TyAlias(..) => DefPathData::TypeNs(ii.ident.name),
+            AssocItemKind::Macro(..) => return self.visit_macro_invoc(ii.id),
         };
 
         let def = self.create_def(ii.id, def_data, ii.span);
index 682ddc421c2878fd27e44e923f7b739516f7a9d3..ad29fd9e1db1e62e1cd5eb7eb4e6c414623a1d34 100644 (file)
@@ -806,7 +806,7 @@ fn resolve_item(&mut self, item: &Item) {
                                 this.with_generic_param_rib(&trait_item.generics, AssocItemRibKind,
                                     |this| {
                                         match trait_item.kind {
-                                            TraitItemKind::Const(ref ty, ref default) => {
+                                            AssocItemKind::Const(ref ty, ref default) => {
                                                 this.visit_ty(ty);
 
                                                 // Only impose the restrictions of
@@ -818,13 +818,13 @@ fn resolve_item(&mut self, item: &Item) {
                                                     });
                                                 }
                                             }
-                                            TraitItemKind::Method(_, _) => {
+                                            AssocItemKind::Method(_, _) => {
                                                 visit::walk_assoc_item(this, trait_item)
                                             }
-                                            TraitItemKind::TyAlias(..) => {
+                                            AssocItemKind::TyAlias(..) => {
                                                 visit::walk_assoc_item(this, trait_item)
                                             }
-                                            TraitItemKind::Macro(_) => {
+                                            AssocItemKind::Macro(_) => {
                                                 panic!("unexpanded macro in resolve!")
                                             }
                                         };
@@ -989,13 +989,13 @@ fn with_current_self_item<T>(&mut self, self_item: &Item, f: impl FnOnce(&mut Se
     /// When evaluating a `trait` use its associated types' idents for suggestionsa in E0412.
     fn with_trait_items<T>(
         &mut self,
-        trait_items: &Vec<TraitItem>,
+        trait_items: &Vec<AssocItem>,
         f: impl FnOnce(&mut Self) -> T,
     ) -> T {
         let trait_assoc_types = replace(
             &mut self.diagnostic_metadata.current_trait_assoc_types,
             trait_items.iter().filter_map(|item| match &item.kind {
-                TraitItemKind::TyAlias(bounds, _) if bounds.len() == 0 => Some(item.ident),
+                AssocItemKind::TyAlias(bounds, _) if bounds.len() == 0 => Some(item.ident),
                 _ => None,
             }).collect(),
         );
@@ -1063,7 +1063,7 @@ fn resolve_implementation(&mut self,
                               opt_trait_reference: &Option<TraitRef>,
                               self_type: &Ty,
                               item_id: NodeId,
-                              impl_items: &[ImplItem]) {
+                              impl_items: &[AssocItem]) {
         debug!("resolve_implementation");
         // If applicable, create a rib for the type parameters.
         self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| {
@@ -1092,9 +1092,9 @@ fn resolve_implementation(&mut self,
                                                                 |this| {
                                         use crate::ResolutionError::*;
                                         match impl_item.kind {
-                                            ImplItemKind::Const(..) => {
+                                            AssocItemKind::Const(..) => {
                                                 debug!(
-                                                    "resolve_implementation ImplItemKind::Const",
+                                                    "resolve_implementation AssocItemKind::Const",
                                                 );
                                                 // If this is a trait impl, ensure the const
                                                 // exists in trait
@@ -1109,7 +1109,7 @@ fn resolve_implementation(&mut self,
                                                     visit::walk_assoc_item(this, impl_item)
                                                 });
                                             }
-                                            ImplItemKind::Method(..) => {
+                                            AssocItemKind::Method(..) => {
                                                 // If this is a trait impl, ensure the method
                                                 // exists in trait
                                                 this.check_trait_item(impl_item.ident,
@@ -1119,7 +1119,7 @@ fn resolve_implementation(&mut self,
 
                                                 visit::walk_assoc_item(this, impl_item);
                                             }
-                                            ImplItemKind::TyAlias(_, Some(ref ty)) => {
+                                            AssocItemKind::TyAlias(_, Some(ref ty)) => {
                                                 // If this is a trait impl, ensure the type
                                                 // exists in trait
                                                 this.check_trait_item(impl_item.ident,
@@ -1129,8 +1129,8 @@ fn resolve_implementation(&mut self,
 
                                                 this.visit_ty(ty);
                                             }
-                                            ImplItemKind::TyAlias(_, None) => {}
-                                            ImplItemKind::Macro(_) =>
+                                            AssocItemKind::TyAlias(_, None) => {}
+                                            AssocItemKind::Macro(_) =>
                                                 panic!("unexpanded macro in resolve!"),
                                         }
                                     });
index cc0f3c512f53ee1fe0ad63f29043eb9078216e92..3b36c1c70f9f2ff905bca78401feae21eee8ba49 100644 (file)
@@ -676,7 +676,7 @@ fn process_impl(
         generics: &'l ast::Generics,
         trait_ref: &'l Option<ast::TraitRef>,
         typ: &'l ast::Ty,
-        impl_items: &'l [ast::ImplItem],
+        impl_items: &'l [ast::AssocItem],
     ) {
         if let Some(impl_data) = self.save_ctxt.get_item_data(item) {
             if !self.span.filter_generated(item.span) {
@@ -707,7 +707,7 @@ fn process_trait(
         item: &'l ast::Item,
         generics: &'l ast::Generics,
         trait_refs: &'l ast::GenericBounds,
-        methods: &'l [ast::TraitItem],
+        methods: &'l [ast::AssocItem],
     ) {
         let name = item.ident.to_string();
         let qualname = format!("::{}",
@@ -1029,11 +1029,11 @@ fn process_macro_use(&mut self, _span: Span) {
         // }
     }
 
-    fn process_trait_item(&mut self, trait_item: &'l ast::TraitItem, trait_id: DefId) {
+    fn process_trait_item(&mut self, trait_item: &'l ast::AssocItem, trait_id: DefId) {
         self.process_macro_use(trait_item.span);
         let vis_span = trait_item.span.shrink_to_lo();
         match trait_item.kind {
-            ast::TraitItemKind::Const(ref ty, ref expr) => {
+            ast::AssocItemKind::Const(ref ty, ref expr) => {
                 self.process_assoc_const(
                     trait_item.id,
                     trait_item.ident,
@@ -1044,7 +1044,7 @@ fn process_trait_item(&mut self, trait_item: &'l ast::TraitItem, trait_id: DefId
                     &trait_item.attrs,
                 );
             }
-            ast::TraitItemKind::Method(ref sig, ref body) => {
+            ast::AssocItemKind::Method(ref sig, ref body) => {
                 self.process_method(
                     sig,
                     body.as_ref().map(|x| &**x),
@@ -1055,7 +1055,7 @@ fn process_trait_item(&mut self, trait_item: &'l ast::TraitItem, trait_id: DefId
                     trait_item.span,
                 );
             }
-            ast::TraitItemKind::TyAlias(ref bounds, ref default_ty) => {
+            ast::AssocItemKind::TyAlias(ref bounds, ref default_ty) => {
                 // FIXME do something with _bounds (for type refs)
                 let name = trait_item.ident.name.to_string();
                 let qualname = format!("::{}",
@@ -1097,14 +1097,14 @@ fn process_trait_item(&mut self, trait_item: &'l ast::TraitItem, trait_id: DefId
                     self.visit_ty(default_ty)
                 }
             }
-            ast::TraitItemKind::Macro(_) => {}
+            ast::AssocItemKind::Macro(_) => {}
         }
     }
 
-    fn process_impl_item(&mut self, impl_item: &'l ast::ImplItem, impl_id: DefId) {
+    fn process_impl_item(&mut self, impl_item: &'l ast::AssocItem, impl_id: DefId) {
         self.process_macro_use(impl_item.span);
         match impl_item.kind {
-            ast::ImplItemKind::Const(ref ty, ref expr) => {
+            ast::AssocItemKind::Const(ref ty, ref expr) => {
                 self.process_assoc_const(
                     impl_item.id,
                     impl_item.ident,
@@ -1115,7 +1115,7 @@ fn process_impl_item(&mut self, impl_item: &'l ast::ImplItem, impl_id: DefId) {
                     &impl_item.attrs,
                 );
             }
-            ast::ImplItemKind::Method(ref sig, ref body) => {
+            ast::AssocItemKind::Method(ref sig, ref body) => {
                 self.process_method(
                     sig,
                     body.as_deref(),
@@ -1126,14 +1126,14 @@ fn process_impl_item(&mut self, impl_item: &'l ast::ImplItem, impl_id: DefId) {
                     impl_item.span,
                 );
             }
-            ast::ImplItemKind::TyAlias(_, None) => {}
-            ast::ImplItemKind::TyAlias(_, Some(ref ty)) => {
+            ast::AssocItemKind::TyAlias(_, None) => {}
+            ast::AssocItemKind::TyAlias(_, Some(ref ty)) => {
                 // FIXME: uses of the assoc type should ideally point to this
                 // 'def' and the name here should be a ref to the def in the
                 // trait.
                 self.visit_ty(ty)
             }
-            ast::ImplItemKind::Macro(_) => {}
+            ast::AssocItemKind::Macro(_) => {}
         }
     }
 
index d90d74d7a262ce2eca590d835644303fa536c993..1b729ebaf43764c9a84061aefe93bcd4fcedcffa 100644 (file)
@@ -1603,16 +1603,10 @@ pub struct FnSig {
     pub decl: P<FnDecl>,
 }
 
-// FIXME(Centril): Remove all of these.
-pub type TraitItem = AssocItem<AssocItemKind>;
-pub type TraitItemKind = AssocItemKind;
-pub type ImplItem = AssocItem<AssocItemKind>;
-pub type ImplItemKind = AssocItemKind;
-
 /// Represents associated items.
 /// These include items in `impl` and `trait` definitions.
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
-pub struct AssocItem<K = ImplItemKind> {
+pub struct AssocItem {
     pub attrs: Vec<Attribute>,
     pub id: NodeId,
     pub span: Span,
@@ -1621,7 +1615,7 @@ pub struct AssocItem<K = ImplItemKind> {
 
     pub defaultness: Defaultness,
     pub generics: Generics,
-    pub kind: K,
+    pub kind: AssocItemKind,
     /// See `Item::tokens` for what this is.
     pub tokens: Option<TokenStream>,
 }
@@ -2598,7 +2592,7 @@ pub enum ItemKind {
     /// A trait declaration (`trait`).
     ///
     /// E.g., `trait Foo { .. }`, `trait Foo<T> { .. }` or `auto trait Foo {}`.
-    Trait(IsAuto, Unsafety, Generics, GenericBounds, Vec<TraitItem>),
+    Trait(IsAuto, Unsafety, Generics, GenericBounds, Vec<AssocItem>),
     /// Trait alias
     ///
     /// E.g., `trait Foo = Bar + Quux;`.
@@ -2613,7 +2607,7 @@ pub enum ItemKind {
         Generics,
         Option<TraitRef>, // (optional) trait this impl implements
         P<Ty>,            // self
-        Vec<ImplItem>,
+        Vec<AssocItem>,
     ),
     /// A macro invocation.
     ///
index c27fcb6a68e0fc76a498e53350dfb44d01e989bd..fcce9d4e95f5af738d289b91be43832c5a9cb29b 100644 (file)
@@ -571,9 +571,9 @@ fn visit_assoc_ty_constraint(&mut self, constraint: &'a AssocTyConstraint) {
         visit::walk_assoc_ty_constraint(self, constraint)
     }
 
-    fn visit_trait_item(&mut self, ti: &'a ast::TraitItem) {
+    fn visit_trait_item(&mut self, ti: &'a ast::AssocItem) {
         match ti.kind {
-            ast::TraitItemKind::Method(ref sig, ref block) => {
+            ast::AssocItemKind::Method(ref sig, ref block) => {
                 if block.is_none() {
                     self.check_extern(sig.header.ext);
                 }
@@ -581,7 +581,7 @@ fn visit_trait_item(&mut self, ti: &'a ast::TraitItem) {
                     gate_feature_post!(&self, const_fn, ti.span, "const fn is unstable");
                 }
             }
-            ast::TraitItemKind::TyAlias(_, ref default) => {
+            ast::AssocItemKind::TyAlias(_, ref default) => {
                 if let Some(_) = default {
                     gate_feature_post!(
                         &self, associated_type_defaults, ti.span,
index 6f45211ac5f2998b5ddec09467cce98674f149a4..263f8192241f2e728fcdafb8ed2272dc5f28a522 100644 (file)
@@ -685,8 +685,8 @@ pub enum Nonterminal {
     // Used only for passing items to proc macro attributes (they are not
     // strictly necessary for that, `Annotatable` can be converted into
     // tokens directly, but doing that naively regresses pretty-printing).
-    NtTraitItem(ast::TraitItem),
-    NtImplItem(ast::ImplItem),
+    NtTraitItem(ast::AssocItem),
+    NtImplItem(ast::AssocItem),
     NtForeignItem(ast::ForeignItem),
 }
 
index a4449ca5b1d22dfab1052f83f612259d56601a62..2cfcbd3161f4dde183b4870cff2faceac25e429b 100644 (file)
@@ -31,8 +31,8 @@
 #[derive(Debug,Clone)]
 pub enum Annotatable {
     Item(P<ast::Item>),
-    TraitItem(P<ast::TraitItem>),
-    ImplItem(P<ast::ImplItem>),
+    TraitItem(P<ast::AssocItem>),
+    ImplItem(P<ast::AssocItem>),
     ForeignItem(P<ast::ForeignItem>),
     Stmt(P<ast::Stmt>),
     Expr(P<ast::Expr>),
@@ -137,14 +137,14 @@ pub fn map_item_or<F, G>(self, mut f: F, mut or: G) -> Annotatable
         }
     }
 
-    pub fn expect_trait_item(self) -> ast::TraitItem {
+    pub fn expect_trait_item(self) -> ast::AssocItem {
         match self {
             Annotatable::TraitItem(i) => i.into_inner(),
             _ => panic!("expected Item")
         }
     }
 
-    pub fn expect_impl_item(self) -> ast::ImplItem {
+    pub fn expect_impl_item(self) -> ast::AssocItem {
         match self {
             Annotatable::ImplItem(i) => i.into_inner(),
             _ => panic!("expected Item")
@@ -382,12 +382,12 @@ fn make_expr(self: Box<Self>) -> Option<P<ast::Expr>> {
     }
 
     /// Creates zero or more impl items.
-    fn make_impl_items(self: Box<Self>) -> Option<SmallVec<[ast::ImplItem; 1]>> {
+    fn make_impl_items(self: Box<Self>) -> Option<SmallVec<[ast::AssocItem; 1]>> {
         None
     }
 
     /// Creates zero or more trait items.
-    fn make_trait_items(self: Box<Self>) -> Option<SmallVec<[ast::TraitItem; 1]>> {
+    fn make_trait_items(self: Box<Self>) -> Option<SmallVec<[ast::AssocItem; 1]>> {
         None
     }
 
@@ -468,8 +468,8 @@ pub fn $fld(v: $t) -> Box<dyn MacResult> {
     expr: P<ast::Expr>,
     pat: P<ast::Pat>,
     items: SmallVec<[P<ast::Item>; 1]>,
-    impl_items: SmallVec<[ast::ImplItem; 1]>,
-    trait_items: SmallVec<[ast::TraitItem; 1]>,
+    impl_items: SmallVec<[ast::AssocItem; 1]>,
+    trait_items: SmallVec<[ast::AssocItem; 1]>,
     foreign_items: SmallVec<[ast::ForeignItem; 1]>,
     stmts: SmallVec<[ast::Stmt; 1]>,
     ty: P<ast::Ty>,
@@ -484,11 +484,11 @@ fn make_expr(self: Box<Self>) -> Option<P<ast::Expr>> {
         self.items
     }
 
-    fn make_impl_items(self: Box<Self>) -> Option<SmallVec<[ast::ImplItem; 1]>> {
+    fn make_impl_items(self: Box<Self>) -> Option<SmallVec<[ast::AssocItem; 1]>> {
         self.impl_items
     }
 
-    fn make_trait_items(self: Box<Self>) -> Option<SmallVec<[ast::TraitItem; 1]>> {
+    fn make_trait_items(self: Box<Self>) -> Option<SmallVec<[ast::AssocItem; 1]>> {
         self.trait_items
     }
 
@@ -588,11 +588,11 @@ fn make_pat(self: Box<DummyResult>) -> Option<P<ast::Pat>> {
         Some(SmallVec::new())
     }
 
-    fn make_impl_items(self: Box<DummyResult>) -> Option<SmallVec<[ast::ImplItem; 1]>> {
+    fn make_impl_items(self: Box<DummyResult>) -> Option<SmallVec<[ast::AssocItem; 1]>> {
         Some(SmallVec::new())
     }
 
-    fn make_trait_items(self: Box<DummyResult>) -> Option<SmallVec<[ast::TraitItem; 1]>> {
+    fn make_trait_items(self: Box<DummyResult>) -> Option<SmallVec<[ast::AssocItem; 1]>> {
         Some(SmallVec::new())
     }
 
index 2eae6d494d07aaa3c806ab70b8afe5bf81713fed..d4223af27abe6ca1dbdee1129b82fc19b9c4a531 100644 (file)
@@ -155,10 +155,10 @@ impl<'a> MacResult for crate::mbe::macro_rules::ParserAnyMacro<'a> {
     Items(SmallVec<[P<ast::Item>; 1]>) {
         "item"; many fn flat_map_item; fn visit_item; fn make_items;
     }
-    TraitItems(SmallVec<[ast::TraitItem; 1]>) {
+    TraitItems(SmallVec<[ast::AssocItem; 1]>) {
         "trait item"; many fn flat_map_trait_item; fn visit_trait_item; fn make_trait_items;
     }
-    ImplItems(SmallVec<[ast::ImplItem; 1]>) {
+    ImplItems(SmallVec<[ast::AssocItem; 1]>) {
         "impl item"; many fn flat_map_impl_item; fn visit_impl_item; fn make_impl_items;
     }
     ForeignItems(SmallVec<[ast::ForeignItem; 1]>) {
index 18acbf2cc13d9b85c9a64f20e8225ffbca860c06..22e99baae5be0e9289e260cdaabd9fef7ae3adfd 100644 (file)
@@ -50,15 +50,15 @@ fn mac_placeholder() -> ast::Mac {
             kind: ast::ItemKind::Mac(mac_placeholder()),
             tokens: None,
         })]),
-        AstFragmentKind::TraitItems => AstFragment::TraitItems(smallvec![ast::TraitItem {
+        AstFragmentKind::TraitItems => AstFragment::TraitItems(smallvec![ast::AssocItem {
             id, span, ident, vis, attrs, generics,
-            kind: ast::TraitItemKind::Macro(mac_placeholder()),
+            kind: ast::AssocItemKind::Macro(mac_placeholder()),
             defaultness: ast::Defaultness::Final,
             tokens: None,
         }]),
-        AstFragmentKind::ImplItems => AstFragment::ImplItems(smallvec![ast::ImplItem {
+        AstFragmentKind::ImplItems => AstFragment::ImplItems(smallvec![ast::AssocItem {
             id, span, ident, vis, attrs, generics,
-            kind: ast::ImplItemKind::Macro(mac_placeholder()),
+            kind: ast::AssocItemKind::Macro(mac_placeholder()),
             defaultness: ast::Defaultness::Final,
             tokens: None,
         }]),
index d51fcf315a69bc75f7ad2c0af8a2816f04d80b2c..1c1fcc4f301bc8eb6bed7bd361f3eef2a15ce82d 100644 (file)
@@ -504,13 +504,13 @@ fn create_derived_impl(&self,
                            type_ident: Ident,
                            generics: &Generics,
                            field_tys: Vec<P<ast::Ty>>,
-                           methods: Vec<ast::ImplItem>)
+                           methods: Vec<ast::AssocItem>)
                            -> P<ast::Item> {
         let trait_path = self.path.to_path(cx, self.span, type_ident, generics);
 
-        // Transform associated types from `deriving::ty::Ty` into `ast::ImplItem`
+        // Transform associated types from `deriving::ty::Ty` into `ast::AssocItem`
         let associated_types = self.associated_types.iter().map(|&(ident, ref type_def)| {
-            ast::ImplItem {
+            ast::AssocItem {
                 id: ast::DUMMY_NODE_ID,
                 span: self.span,
                 ident,
@@ -518,7 +518,7 @@ fn create_derived_impl(&self,
                 defaultness: ast::Defaultness::Final,
                 attrs: Vec::new(),
                 generics: Generics::default(),
-                kind: ast::ImplItemKind::TyAlias(
+                kind: ast::AssocItemKind::TyAlias(
                     Vec::new(),
                     Some(type_def.to_ty(cx, self.span, type_ident, generics)),
                 ),
@@ -912,7 +912,7 @@ fn create_method(&self,
                      explicit_self: Option<ast::ExplicitSelf>,
                      arg_types: Vec<(Ident, P<ast::Ty>)>,
                      body: P<Expr>)
-                     -> ast::ImplItem {
+                     -> ast::AssocItem {
         // Create the generics that aren't for `Self`.
         let fn_generics = self.generics.to_generics(cx, trait_.span, type_ident, generics);
 
@@ -950,7 +950,7 @@ fn create_method(&self,
         };
 
         // Create the method.
-        ast::ImplItem {
+        ast::AssocItem {
             id: ast::DUMMY_NODE_ID,
             attrs: self.attributes.clone(),
             generics: fn_generics,
@@ -958,7 +958,7 @@ fn create_method(&self,
             vis: respan(trait_lo_sp, ast::VisibilityKind::Inherited),
             defaultness: ast::Defaultness::Final,
             ident: method_ident,
-            kind: ast::ImplItemKind::Method(sig, Some(body_block)),
+            kind: ast::AssocItemKind::Method(sig, Some(body_block)),
             tokens: None,
         }
     }