]> git.lizzy.rs Git - rust.git/commitdiff
`AssocImplKind::{Method -> Fn}`.
authorMazdak Farrokhzad <twingoow@gmail.com>
Sat, 7 Dec 2019 23:13:59 +0000 (00:13 +0100)
committerMazdak Farrokhzad <twingoow@gmail.com>
Thu, 12 Dec 2019 17:05:05 +0000 (18:05 +0100)
16 files changed:
src/librustc/hir/lowering.rs
src/librustc/hir/lowering/item.rs
src/librustc_interface/util.rs
src/librustc_lint/builtin.rs
src/librustc_parse/parser/item.rs
src/librustc_passes/ast_validation.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/mut_visit.rs
src/libsyntax/print/pprust.rs
src/libsyntax/visit.rs
src/libsyntax_ext/deriving/generic/mod.rs

index 78df14adc5d6d3a90d22e657878ec883cc41e952..50733512faec800dd2534de775f67645fb464cb2 100644 (file)
@@ -481,7 +481,7 @@ fn visit_trait_item(&mut self, item: &'tcx AssocItem) {
                 self.lctx.allocate_hir_id_counter(item.id);
 
                 match item.kind {
-                    AssocItemKind::Method(_, None) => {
+                    AssocItemKind::Fn(_, None) => {
                         // Ignore patterns in trait methods without bodies
                         self.with_hir_id_owner(None, |this| {
                             visit::walk_trait_item(this, item)
index f25714f741b8da45737b66d3ce89612738904cfe..f0543b9057d1f7b1175143d79190a63e51efda9a 100644 (file)
@@ -826,7 +826,7 @@ fn lower_trait_item(&mut self, i: &AssocItem) -> hir::TraitItem {
                         .map(|x| self.lower_const_body(i.span, Some(x))),
                 ),
             ),
-            AssocItemKind::Method(ref sig, None) => {
+            AssocItemKind::Fn(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: &AssocItem) -> hir::TraitItem {
                 );
                 (generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Required(names)))
             }
-            AssocItemKind::Method(ref sig, Some(ref body)) => {
+            AssocItemKind::Fn(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,
@@ -880,7 +880,7 @@ fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemRef {
             AssocItemKind::TyAlias(_, ref default) => {
                 (hir::AssocItemKind::Type, default.is_some())
             }
-            AssocItemKind::Method(ref sig, ref default) => (
+            AssocItemKind::Fn(ref sig, ref default) => (
                 hir::AssocItemKind::Method {
                     has_self: sig.decl.has_self(),
                 },
@@ -913,7 +913,7 @@ fn lower_impl_item(&mut self, i: &AssocItem) -> hir::ImplItem {
                     self.lower_const_body(i.span, expr.as_deref()),
                 ),
             ),
-            AssocItemKind::Method(ref sig, ref body) => {
+            AssocItemKind::Fn(ref sig, ref body) => {
                 self.current_item = Some(i.span);
                 let body_id = self.lower_maybe_async_body(
                     i.span,
@@ -984,7 +984,7 @@ fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemRef {
                     None => hir::AssocItemKind::Type,
                     Some(_) => hir::AssocItemKind::OpaqueTy,
                 },
-                AssocItemKind::Method(sig, _) => hir::AssocItemKind::Method {
+                AssocItemKind::Fn(sig, _) => hir::AssocItemKind::Method {
                     has_self: sig.decl.has_self(),
                 },
                 AssocItemKind::Macro(..) => unimplemented!(),
index da8eae6028e36070c1a8bd3030d67a8b09a23ab4..e84ac82942c8e123e489d00e9c79016e0d381154 100644 (file)
@@ -779,7 +779,7 @@ fn visit_item_kind(&mut self, i: &mut ast::ItemKind) {
     fn flat_map_trait_item(&mut self, i: ast::AssocItem) -> SmallVec<[ast::AssocItem; 1]> {
         let is_const = match i.kind {
             ast::AssocItemKind::Const(..) => true,
-            ast::AssocItemKind::Method(ref sig, _) => Self::is_sig_const(sig),
+            ast::AssocItemKind::Fn(ref sig, _) => Self::is_sig_const(sig),
             _ => false,
         };
         self.run(is_const, |s| noop_flat_map_assoc_item(i, s))
index 8916fc088387156d4b36b49df8ffcaea17bf66d0..1fc89961889f1ba9fe51f0d86851e374e7531619 100644 (file)
@@ -269,7 +269,7 @@ fn check_fn(&mut self,
     }
 
     fn check_trait_item(&mut self, cx: &EarlyContext<'_>, item: &ast::AssocItem) {
-        if let ast::AssocItemKind::Method(ref sig, None) = item.kind {
+        if let ast::AssocItemKind::Fn(ref sig, None) = item.kind {
             if sig.header.unsafety == ast::Unsafety::Unsafe {
                 self.report_unsafe(cx, item.span, "declaration of an `unsafe` method")
             }
@@ -617,7 +617,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
 impl EarlyLintPass for AnonymousParameters {
     fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::AssocItem) {
         match it.kind {
-            ast::AssocItemKind::Method(ref sig, _) => {
+            ast::AssocItemKind::Fn(ref sig, _) => {
                 for arg in sig.decl.inputs.iter() {
                     match arg.pat.kind {
                         ast::PatKind::Ident(_, ident, None) => {
index a7c98886622807a30d5722d168d0237879b32b6b..0840a1551dbf4fd1da7c909b365efca5d2b07273 100644 (file)
@@ -1790,7 +1790,7 @@ fn parse_assoc_fn(
         })?;
         let sig = FnSig { header, decl };
         let body = self.parse_assoc_fn_body(at_end, attrs)?;
-        Ok((ident, AssocItemKind::Method(sig, body), generics))
+        Ok((ident, AssocItemKind::Fn(sig, body), generics))
     }
 
     /// Parse the "body" of a method in an associated item definition.
index 609885cb254b77ae565967b95a5ebae7b558c738..e90231f984b1f8a020a78a31e8378c2929cf3226 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 AssocItemKind::Method(ref sig, _) = impl_item.kind {
+                    if let AssocItemKind::Fn(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);
                     }
@@ -795,7 +795,7 @@ fn visit_impl_item(&mut self, ii: &'a AssocItem) {
             AssocItemKind::Const(_, body) => {
                 self.check_impl_item_provided(ii.span, body, "constant", " = <expr>;");
             }
-            AssocItemKind::Method(sig, body) => {
+            AssocItemKind::Fn(sig, body) => {
                 self.check_impl_item_provided(ii.span, body, "function", " { <body> }");
                 self.check_fn_decl(&sig.decl);
             }
@@ -812,7 +812,7 @@ fn visit_trait_item(&mut self, ti: &'a AssocItem) {
         self.invalid_visibility(&ti.vis, None);
         self.check_defaultness(ti.span, ti.defaultness);
 
-        if let AssocItemKind::Method(sig, block) = &ti.kind {
+        if let AssocItemKind::Fn(sig, block) = &ti.kind {
             self.check_fn_decl(&sig.decl);
             self.check_trait_fn_not_async(ti.span, sig.header.asyncness.node);
             self.check_trait_fn_not_const(sig.header.constness);
@@ -838,7 +838,7 @@ fn visit_trait_item(&mut self, ti: &'a AssocItem) {
     }
 
     fn visit_assoc_item(&mut self, item: &'a AssocItem) {
-        if let AssocItemKind::Method(sig, _) = &item.kind {
+        if let AssocItemKind::Fn(sig, _) = &item.kind {
             self.check_c_varadic_type(&sig.decl);
         }
         visit::walk_assoc_item(self, item);
index dc3013754404b39323a6e5ce6f9d9d80248d38e7..e94e0dc695cd605abe8fcb673dff3fa8e36402fb 100644 (file)
@@ -1176,7 +1176,7 @@ fn visit_trait_item(&mut self, item: &'b AssocItem) {
         let item_def_id = self.r.definitions.local_def_id(item.id);
         let (res, ns) = match item.kind {
             AssocItemKind::Const(..) => (Res::Def(DefKind::AssocConst, item_def_id), ValueNS),
-            AssocItemKind::Method(ref sig, _) => {
+            AssocItemKind::Fn(ref sig, _) => {
                 if sig.decl.has_self() {
                     self.r.has_self.insert(item_def_id);
                 }
index 6e26553d82f8262fe5e3272fd189d476f2e22d95..9bae339f80ea4e1d4b1571215225df3fe0eadc17 100644 (file)
@@ -214,11 +214,8 @@ fn visit_generic_param(&mut self, param: &'a GenericParam) {
 
     fn visit_trait_item(&mut self, ti: &'a AssocItem) {
         let def_data = match ti.kind {
-            AssocItemKind::Method(..) | AssocItemKind::Const(..) =>
-                DefPathData::ValueNs(ti.ident.name),
-            AssocItemKind::TyAlias(..) => {
-                DefPathData::TypeNs(ti.ident.name)
-            },
+            AssocItemKind::Fn(..) | AssocItemKind::Const(..) => DefPathData::ValueNs(ti.ident.name),
+            AssocItemKind::TyAlias(..) => DefPathData::TypeNs(ti.ident.name),
             AssocItemKind::Macro(..) => return self.visit_macro_invoc(ti.id),
         };
 
@@ -228,7 +225,7 @@ fn visit_trait_item(&mut self, ti: &'a AssocItem) {
 
     fn visit_impl_item(&mut self, ii: &'a AssocItem) {
         let def_data = match ii.kind {
-            AssocItemKind::Method(FnSig {
+            AssocItemKind::Fn(FnSig {
                 ref header,
                 ref decl,
             }, ref body) if header.asyncness.node.is_async() => {
@@ -242,7 +239,7 @@ fn visit_impl_item(&mut self, ii: &'a AssocItem) {
                     body.as_deref(),
                 )
             }
-            AssocItemKind::Method(..) |
+            AssocItemKind::Fn(..) |
             AssocItemKind::Const(..) => DefPathData::ValueNs(ii.ident.name),
             AssocItemKind::TyAlias(..) => DefPathData::TypeNs(ii.ident.name),
             AssocItemKind::Macro(..) => return self.visit_macro_invoc(ii.id),
index ad29fd9e1db1e62e1cd5eb7eb4e6c414623a1d34..ec9c2a5b75d83030c4104122646586ca310ae5ba 100644 (file)
@@ -818,7 +818,7 @@ fn resolve_item(&mut self, item: &Item) {
                                                     });
                                                 }
                                             }
-                                            AssocItemKind::Method(_, _) => {
+                                            AssocItemKind::Fn(_, _) => {
                                                 visit::walk_assoc_item(this, trait_item)
                                             }
                                             AssocItemKind::TyAlias(..) => {
@@ -1109,7 +1109,7 @@ fn resolve_implementation(&mut self,
                                                     visit::walk_assoc_item(this, impl_item)
                                                 });
                                             }
-                                            AssocItemKind::Method(..) => {
+                                            AssocItemKind::Fn(..) => {
                                                 // If this is a trait impl, ensure the method
                                                 // exists in trait
                                                 this.check_trait_item(impl_item.ident,
index 3b36c1c70f9f2ff905bca78401feae21eee8ba49..df6ad51d1045b9c54bacdff460a0a4b614b3fc63 100644 (file)
@@ -1044,7 +1044,7 @@ fn process_trait_item(&mut self, trait_item: &'l ast::AssocItem, trait_id: DefId
                     &trait_item.attrs,
                 );
             }
-            ast::AssocItemKind::Method(ref sig, ref body) => {
+            ast::AssocItemKind::Fn(ref sig, ref body) => {
                 self.process_method(
                     sig,
                     body.as_ref().map(|x| &**x),
@@ -1115,7 +1115,7 @@ fn process_impl_item(&mut self, impl_item: &'l ast::AssocItem, impl_id: DefId) {
                     &impl_item.attrs,
                 );
             }
-            ast::AssocItemKind::Method(ref sig, ref body) => {
+            ast::AssocItemKind::Fn(ref sig, ref body) => {
                 self.process_method(
                     sig,
                     body.as_deref(),
index 1b729ebaf43764c9a84061aefe93bcd4fcedcffa..f7f84333857f6ed1bfd396bf312fdd78a75655a0 100644 (file)
@@ -1634,8 +1634,7 @@ pub enum AssocItemKind  {
     Const(P<Ty>, Option<P<Expr>>),
 
     /// An associated function.
-    /// FIXME(Centril): Rename to `Fn`.
-    Method(FnSig, Option<P<Block>>),
+    Fn(FnSig, Option<P<Block>>),
 
     /// An associated type.
     TyAlias(GenericBounds, Option<P<Ty>>),
index fcce9d4e95f5af738d289b91be43832c5a9cb29b..871ec2c008eee384aa8df52f1915346e3eebeff4 100644 (file)
@@ -573,7 +573,7 @@ fn visit_assoc_ty_constraint(&mut self, constraint: &'a AssocTyConstraint) {
 
     fn visit_trait_item(&mut self, ti: &'a ast::AssocItem) {
         match ti.kind {
-            ast::AssocItemKind::Method(ref sig, ref block) => {
+            ast::AssocItemKind::Fn(ref sig, ref block) => {
                 if block.is_none() {
                     self.check_extern(sig.header.ext);
                 }
@@ -600,7 +600,7 @@ fn visit_assoc_item(&mut self, ii: &'a ast::AssocItem) {
         }
 
         match ii.kind {
-            ast::AssocItemKind::Method(ref sig, _) => {
+            ast::AssocItemKind::Fn(ref sig, _) => {
                 if sig.decl.c_variadic() {
                     gate_feature_post!(
                         &self, c_variadic, ii.span,
index 18d42f9dd668c69f7988534d2f64292a74444494..2a6cff5971c57e0b8c5629f9750b613d2ddb1028 100644 (file)
@@ -955,7 +955,7 @@ pub fn noop_flat_map_assoc_item<T: MutVisitor>(mut item: AssocItem, visitor: &mu
             visitor.visit_ty(ty);
             visit_opt(expr, |expr| visitor.visit_expr(expr));
         }
-        AssocItemKind::Method(sig, body) => {
+        AssocItemKind::Fn(sig, body) => {
             visit_fn_sig(sig, visitor);
             visit_opt(body, |body| visitor.visit_block(body));
         }
index 9e4615f60c03c9e2b95613ef226bd5f6b47fd0b1..87f6ae85b6970a2a1ed0dca4e5d28783674dfa02 100644 (file)
@@ -1528,7 +1528,7 @@ fn print_poly_trait_ref(&mut self, t: &ast::PolyTraitRef) {
             ast::AssocItemKind::Const(ty, expr) => {
                 self.print_associated_const(item.ident, ty, expr.as_deref(), &item.vis);
             }
-            ast::AssocItemKind::Method(sig, body) => {
+            ast::AssocItemKind::Fn(sig, body) => {
                 if body.is_some() {
                     self.head("");
                 }
index e2c0ee614674139da47e5b2f04baf67eb4917adc..51e7fa1eb38b49bd94546e9f34cf597f287912ab 100644 (file)
@@ -600,11 +600,11 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a AssocItem)
             visitor.visit_ty(ty);
             walk_list!(visitor, visit_expr, expr);
         }
-        AssocItemKind::Method(ref sig, None) => {
+        AssocItemKind::Fn(ref sig, None) => {
             visitor.visit_fn_header(&sig.header);
             walk_fn_decl(visitor, &sig.decl);
         }
-        AssocItemKind::Method(ref sig, Some(ref body)) => {
+        AssocItemKind::Fn(ref sig, Some(ref body)) => {
             visitor.visit_fn(FnKind::Method(item.ident, sig, &item.vis, body),
                              &sig.decl, item.span, item.id);
         }
index 1c1fcc4f301bc8eb6bed7bd361f3eef2a15ce82d..b7707bfb8e5fbd95f6f536ecf56811e54c708ac3 100644 (file)
@@ -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::AssocItemKind::Method(sig, Some(body_block)),
+            kind: ast::AssocItemKind::Fn(sig, Some(body_block)),
             tokens: None,
         }
     }