From 98c7ed67fb00c3eac8f1baa3ea24bc903f83e550 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Tue, 3 Mar 2020 12:29:07 -0600 Subject: [PATCH 1/2] DefKind::Method -> DefKind::AssocFn --- src/librustc/hir/map/mod.rs | 4 ++-- src/librustc/middle/stability.rs | 2 +- src/librustc/ty/context.rs | 2 +- src/librustc/ty/mod.rs | 6 +++--- src/librustc_ast_lowering/path.rs | 2 +- src/librustc_hir/def.rs | 7 ++++--- src/librustc_infer/infer/error_reporting/need_type_info.rs | 2 +- src/librustc_lint/unused.rs | 2 +- src/librustc_metadata/rmeta/decoder.rs | 2 +- src/librustc_mir/util/pretty.rs | 2 +- src/librustc_mir_build/hair/cx/expr.rs | 4 ++-- src/librustc_privacy/lib.rs | 4 ++-- src/librustc_resolve/build_reduced_graph.rs | 6 +++--- src/librustc_resolve/late.rs | 4 ++-- src/librustc_resolve/late/diagnostics.rs | 2 +- src/librustc_resolve/lib.rs | 2 +- src/librustc_save_analysis/lib.rs | 2 +- src/librustc_typeck/astconv.rs | 2 +- src/librustc_typeck/check/generator_interior.rs | 2 +- src/librustc_typeck/check/mod.rs | 4 ++-- src/librustc_typeck/check/pat.rs | 6 +++--- src/librustc_typeck/mem_categorization.rs | 2 +- src/librustdoc/passes/collect_intra_doc_links.rs | 4 ++-- 23 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 4f7c4153ea173..2374d47ae8ee7 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -326,12 +326,12 @@ impl<'hir> Map<'hir> { }, Node::TraitItem(item) => match item.kind { TraitItemKind::Const(..) => DefKind::AssocConst, - TraitItemKind::Method(..) => DefKind::Method, + TraitItemKind::Method(..) => DefKind::AssocFn, TraitItemKind::Type(..) => DefKind::AssocTy, }, Node::ImplItem(item) => match item.kind { ImplItemKind::Const(..) => DefKind::AssocConst, - ImplItemKind::Method(..) => DefKind::Method, + ImplItemKind::Method(..) => DefKind::AssocFn, ImplItemKind::TyAlias(..) => DefKind::AssocTy, ImplItemKind::OpaqueTy(..) => DefKind::AssocOpaqueTy, }, diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 9d3df9623bd62..1f6725fb3950f 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -250,7 +250,7 @@ pub enum EvalResult { fn skip_stability_check_due_to_privacy(tcx: TyCtxt<'_>, mut def_id: DefId) -> bool { // Check if `def_id` is a trait method. match tcx.def_kind(def_id) { - Some(DefKind::Method) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => { + Some(DefKind::AssocFn) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => { if let ty::TraitContainer(trait_def_id) = tcx.associated_item(def_id).container { // Trait methods do not declare visibility (even // for visibility info in cstore). Use containing diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 20736b50831bb..ec9ff55ffe431 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -611,7 +611,7 @@ impl<'tcx> TypeckTables<'tcx> { } match self.type_dependent_defs().get(expr.hir_id) { - Some(Ok((DefKind::Method, _))) => true, + Some(Ok((DefKind::AssocFn, _))) => true, _ => false, } } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index b25fd3c61fd5d..546686c20caa7 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -230,7 +230,7 @@ impl AssocItem { pub fn def_kind(&self) -> DefKind { match self.kind { AssocKind::Const => DefKind::AssocConst, - AssocKind::Method => DefKind::Method, + AssocKind::Method => DefKind::AssocFn, AssocKind::Type => DefKind::AssocTy, AssocKind::OpaqueTy => DefKind::AssocOpaqueTy, } @@ -2872,7 +2872,7 @@ impl<'tcx> TyCtxt<'tcx> { } } else { match self.def_kind(def_id).expect("no def for `DefId`") { - DefKind::AssocConst | DefKind::Method | DefKind::AssocTy => true, + DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy => true, _ => false, } }; @@ -3051,7 +3051,7 @@ impl<'tcx> TyCtxt<'tcx> { /// `DefId` of the impl that the method belongs to; otherwise, returns `None`. pub fn impl_of_method(self, def_id: DefId) -> Option { let item = if def_id.krate != LOCAL_CRATE { - if let Some(DefKind::Method) = self.def_kind(def_id) { + if let Some(DefKind::AssocFn) = self.def_kind(def_id) { Some(self.associated_item(def_id)) } else { None diff --git a/src/librustc_ast_lowering/path.rs b/src/librustc_ast_lowering/path.rs index 80d7e3d0d465a..db8517bfbf0c7 100644 --- a/src/librustc_ast_lowering/path.rs +++ b/src/librustc_ast_lowering/path.rs @@ -75,7 +75,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { ParenthesizedGenericArgs::Ok } // `a::b::Trait(Args)::TraitItem` - Res::Def(DefKind::Method, _) + Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::AssocTy, _) if i + 2 == proj_start => diff --git a/src/librustc_hir/def.rs b/src/librustc_hir/def.rs index 595543eaf535f..5b2c1453de642 100644 --- a/src/librustc_hir/def.rs +++ b/src/librustc_hir/def.rs @@ -72,7 +72,7 @@ pub enum DefKind { Static, /// Refers to the struct or enum variant's constructor. Ctor(CtorOf, CtorKind), - Method, + AssocFn, AssocConst, // Macro namespace @@ -107,7 +107,8 @@ impl DefKind { DefKind::Union => "union", DefKind::Trait => "trait", DefKind::ForeignTy => "foreign type", - DefKind::Method => "method", + // FIXME: Update the description to "assoc fn" + DefKind::AssocFn => "method", DefKind::Const => "constant", DefKind::AssocConst => "associated constant", DefKind::TyParam => "type parameter", @@ -150,7 +151,7 @@ impl DefKind { | DefKind::ConstParam | DefKind::Static | DefKind::Ctor(..) - | DefKind::Method + | DefKind::AssocFn | DefKind::AssocConst => ns == Namespace::ValueNS, DefKind::Macro(..) => ns == Namespace::MacroNS, diff --git a/src/librustc_infer/infer/error_reporting/need_type_info.rs b/src/librustc_infer/infer/error_reporting/need_type_info.rs index a1e6a0a325ada..56f8c8c2b9c76 100644 --- a/src/librustc_infer/infer/error_reporting/need_type_info.rs +++ b/src/librustc_infer/infer/error_reporting/need_type_info.rs @@ -468,7 +468,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { &segment.args, ) { let borrow = tables.borrow(); - if let Some((DefKind::Method, did)) = borrow.type_dependent_def(e.hir_id) { + if let Some((DefKind::AssocFn, did)) = borrow.type_dependent_def(e.hir_id) { let generics = self.tcx.generics_of(did); if !generics.params.is_empty() { err.span_suggestion( diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 02f04b2345932..49d05819c5ec9 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -54,7 +54,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { match callee.kind { hir::ExprKind::Path(ref qpath) => { match cx.tables.qpath_res(qpath, callee.hir_id) { - Res::Def(DefKind::Fn, def_id) | Res::Def(DefKind::Method, def_id) => { + Res::Def(DefKind::Fn, def_id) | Res::Def(DefKind::AssocFn, def_id) => { Some(def_id) } // `Res::Local` if it was a closure, for which we diff --git a/src/librustc_metadata/rmeta/decoder.rs b/src/librustc_metadata/rmeta/decoder.rs index a72ee0cbe4729..d0a35c6156436 100644 --- a/src/librustc_metadata/rmeta/decoder.rs +++ b/src/librustc_metadata/rmeta/decoder.rs @@ -504,7 +504,7 @@ impl EntryKind { EntryKind::Struct(_, _) => DefKind::Struct, EntryKind::Union(_, _) => DefKind::Union, EntryKind::Fn(_) | EntryKind::ForeignFn(_) => DefKind::Fn, - EntryKind::Method(_) => DefKind::Method, + EntryKind::Method(_) => DefKind::AssocFn, EntryKind::Type => DefKind::TyAlias, EntryKind::TypeParam => DefKind::TyParam, EntryKind::ConstParam => DefKind::ConstParam, diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 6fd8f06fe8f25..ee8de0e6b9311 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -545,7 +545,7 @@ fn write_mir_sig( trace!("write_mir_sig: {:?}", src.instance); let kind = tcx.def_kind(src.def_id()); let is_function = match kind { - Some(DefKind::Fn) | Some(DefKind::Method) | Some(DefKind::Ctor(..)) => true, + Some(DefKind::Fn) | Some(DefKind::AssocFn) | Some(DefKind::Ctor(..)) => true, _ => tcx.is_closure(src.def_id()), }; match (kind, src.promoted) { diff --git a/src/librustc_mir_build/hair/cx/expr.rs b/src/librustc_mir_build/hair/cx/expr.rs index 46d49b6b4933f..9f04bc1dc7697 100644 --- a/src/librustc_mir_build/hair/cx/expr.rs +++ b/src/librustc_mir_build/hair/cx/expr.rs @@ -600,7 +600,7 @@ fn user_substs_applied_to_res<'tcx>( // a tuple-struct or tuple-variant. This has the type of a // `Fn` but with the user-given substitutions. Res::Def(DefKind::Fn, _) - | Res::Def(DefKind::Method, _) + | Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) | Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) => { @@ -703,7 +703,7 @@ fn convert_path_expr<'a, 'tcx>( match res { // A regular function, constructor function or a constant. Res::Def(DefKind::Fn, _) - | Res::Def(DefKind::Method, _) + | Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) | Res::SelfCtor(..) => { let user_ty = user_substs_applied_to_res(cx, expr.hir_id, res); diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 24696b203326f..175b2390d3083 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -620,7 +620,7 @@ impl EmbargoVisitor<'tcx> { | DefKind::ForeignTy | DefKind::Fn | DefKind::OpaqueTy - | DefKind::Method + | DefKind::AssocFn | DefKind::Trait | DefKind::TyParam | DefKind::Variant => (), @@ -1298,7 +1298,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { _ => None, }; let def = def.filter(|(kind, _)| match kind { - DefKind::Method + DefKind::AssocFn | DefKind::AssocConst | DefKind::AssocTy | DefKind::AssocOpaqueTy diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 86816fd9f3a2a..1fc99e40d8303 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -887,7 +887,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { | Res::PrimTy(..) | Res::ToolMod => self.r.define(parent, ident, TypeNS, (res, vis, span, expansion)), Res::Def(DefKind::Fn, _) - | Res::Def(DefKind::Method, _) + | Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::Static, _) | Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) @@ -911,7 +911,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { let field_names = cstore.struct_field_names_untracked(def_id, self.r.session); self.insert_field_names(def_id, field_names); } - Res::Def(DefKind::Method, def_id) => { + Res::Def(DefKind::AssocFn, def_id) => { if cstore.associated_item_cloned_untracked(def_id).method_has_self_argument { self.r.has_self.insert(def_id); } @@ -1257,7 +1257,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { if sig.decl.has_self() { self.r.has_self.insert(item_def_id); } - (Res::Def(DefKind::Method, item_def_id), ValueNS) + (Res::Def(DefKind::AssocFn, item_def_id), ValueNS) } AssocItemKind::TyAlias(..) => (Res::Def(DefKind::AssocTy, item_def_id), TypeNS), AssocItemKind::Macro(_) => bug!(), // handled above diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index e5aa9c7d8962a..640b07d3d62be 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -266,7 +266,7 @@ impl<'a> PathSource<'a> { | Res::Def(DefKind::Static, _) | Res::Local(..) | Res::Def(DefKind::Fn, _) - | Res::Def(DefKind::Method, _) + | Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::AssocConst, _) | Res::SelfCtor(..) | Res::Def(DefKind::ConstParam, _) => true, @@ -293,7 +293,7 @@ impl<'a> PathSource<'a> { _ => false, }, PathSource::TraitItem(ns) => match res { - Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::Method, _) + Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::AssocFn, _) if ns == ValueNS => { true diff --git a/src/librustc_resolve/late/diagnostics.rs b/src/librustc_resolve/late/diagnostics.rs index 817a276ff3e73..a9463d970ce4b 100644 --- a/src/librustc_resolve/late/diagnostics.rs +++ b/src/librustc_resolve/late/diagnostics.rs @@ -124,7 +124,7 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> { .unwrap_or(false) } Res::Def(DefKind::Ctor(..), _) - | Res::Def(DefKind::Method, _) + | Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) | Res::SelfCtor(_) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 44eba0d533d3a..3a39331446344 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -742,7 +742,7 @@ impl<'a> NameBinding<'a> { fn is_importable(&self) -> bool { match self.res() { Res::Def(DefKind::AssocConst, _) - | Res::Def(DefKind::Method, _) + | Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::AssocTy, _) => false, _ => true, } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index c68289adb1059..2bd335421e0f4 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -716,7 +716,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> { | Res::Def(HirDefKind::Ctor(..), _) => { Some(Ref { kind: RefKind::Variable, span, ref_id: id_from_def_id(res.def_id()) }) } - Res::Def(HirDefKind::Method, decl_id) => { + Res::Def(HirDefKind::AssocFn, decl_id) => { let def_id = if decl_id.is_local() { let ti = self.tcx.associated_item(decl_id); diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 199b476cb9a3e..d59923a0019f4 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -2588,7 +2588,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } // Case 4. Reference to a method or associated const. - DefKind::Method | DefKind::AssocConst => { + DefKind::AssocFn | DefKind::AssocConst => { if segments.len() >= 2 { let generics = tcx.generics_of(def_id); path_segs.push(PathSeg(generics.parent.unwrap(), last - 1)); diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index 50692e0f10487..7e52657377393 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -237,7 +237,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> { // ZST in a temporary, so skip its type, just in case it // can significantly complicate the generator type. Res::Def(DefKind::Fn, _) - | Res::Def(DefKind::Method, _) + | Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) => { // NOTE(eddyb) this assumes a path expression has // no nested expressions to keep track of. diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index b7353c6af267a..fd5cac5b24bf1 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2976,7 +2976,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn write_method_call(&self, hir_id: hir::HirId, method: MethodCallee<'tcx>) { debug!("write_method_call(hir_id={:?}, method={:?})", hir_id, method); - self.write_resolution(hir_id, Ok((DefKind::Method, method.def_id))); + self.write_resolution(hir_id, Ok((DefKind::AssocFn, method.def_id))); self.write_substs(hir_id, method.substs); // When the method is confirmed, the `method.substs` includes @@ -5364,7 +5364,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { is_alias_variant_ctor = true; } } - Res::Def(DefKind::Method, def_id) | Res::Def(DefKind::AssocConst, def_id) => { + Res::Def(DefKind::AssocFn, def_id) | Res::Def(DefKind::AssocConst, def_id) => { let container = tcx.associated_item(def_id).container; debug!("instantiate_value_path: def_id={:?} container={:?}", def_id, container); match container { diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index b7aac707a9838..c50274d19e3f6 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -682,7 +682,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.set_tainted_by_errors(); return tcx.types.err; } - Res::Def(DefKind::Method, _) + Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::Ctor(_, CtorKind::Fictive), _) | Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) => { report_unexpected_variant_res(tcx, res, pat.span, qpath); @@ -729,7 +729,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); let mut err = struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg); match (res, &pat.kind) { - (Res::Def(DefKind::Fn, _), _) | (Res::Def(DefKind::Method, _), _) => { + (Res::Def(DefKind::Fn, _), _) | (Res::Def(DefKind::AssocFn, _), _) => { err.span_label(pat.span, "`fn` calls are not allowed in patterns"); err.help( "for more information, visit \ @@ -766,7 +766,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { on_error(); return tcx.types.err; } - Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::Method, _) => { + Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::AssocFn, _) => { report_unexpected_res(res); return tcx.types.err; } diff --git a/src/librustc_typeck/mem_categorization.rs b/src/librustc_typeck/mem_categorization.rs index a4569a147567f..8e06948a10953 100644 --- a/src/librustc_typeck/mem_categorization.rs +++ b/src/librustc_typeck/mem_categorization.rs @@ -425,7 +425,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { | Res::Def(DefKind::ConstParam, _) | Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::Fn, _) - | Res::Def(DefKind::Method, _) + | Res::Def(DefKind::AssocFn, _) | Res::SelfCtor(..) => Ok(self.cat_rvalue(hir_id, span, expr_ty)), Res::Def(DefKind::Static, _) => Ok(Place { diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 7aa90d667813f..75355b84fee83 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -149,7 +149,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { // In case this is a trait item, skip the // early return and try looking for the trait. let value = match res { - Res::Def(DefKind::Method, _) | Res::Def(DefKind::AssocConst, _) => true, + Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::AssocConst, _) => true, Res::Def(DefKind::AssocTy, _) => false, Res::Def(DefKind::Variant, _) => { return handle_variant(cx, res, extra_fragment); @@ -813,7 +813,7 @@ fn ambiguity_error( for (res, ns) in candidates { let (action, mut suggestion) = match res { - Res::Def(DefKind::Method, _) | Res::Def(DefKind::Fn, _) => { + Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::Fn, _) => { ("add parentheses", format!("{}()", path_str)) } Res::Def(DefKind::Macro(..), _) => { From 3aeb9f0fafd33a425a67b7ee44f30f98dde64642 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Tue, 3 Mar 2020 12:46:22 -0600 Subject: [PATCH 2/2] rename TraitItemKind::Method -> Fn --- src/librustc/hir/map/blocks.rs | 4 ++-- src/librustc/hir/map/mod.rs | 14 +++++++------- src/librustc_ast_lowering/item.rs | 4 ++-- src/librustc_hir/hir.rs | 6 +++--- src/librustc_hir/intravisit.rs | 4 ++-- src/librustc_hir/print.rs | 4 ++-- src/librustc_hir/target.rs | 4 ++-- src/librustc_incremental/persist/dirty_clean.rs | 2 +- src/librustc_infer/infer/error_reporting/mod.rs | 2 +- .../nice_region_error/find_anon_type.rs | 2 +- .../traits/error_reporting/on_unimplemented.rs | 2 +- .../traits/error_reporting/suggestions.rs | 6 +++--- src/librustc_lint/builtin.rs | 2 +- src/librustc_lint/nonstandard_style.rs | 2 +- src/librustc_metadata/rmeta/encoder.rs | 2 +- .../borrow_check/diagnostics/mutability_errors.rs | 4 ++-- src/librustc_mir_build/build/mod.rs | 2 +- src/librustc_passes/dead.rs | 6 +++--- src/librustc_passes/reachable.rs | 8 ++++---- src/librustc_resolve/late/lifetimes.rs | 9 +++------ src/librustc_traits/lowering/environment.rs | 2 +- src/librustc_typeck/check/compare_method.rs | 10 +++++----- src/librustc_typeck/check/method/suggest.rs | 2 +- src/librustc_typeck/check/mod.rs | 10 +++++----- src/librustc_typeck/check/wfcheck.rs | 4 ++-- src/librustc_typeck/collect.rs | 8 ++++---- src/librustc_typeck/collect/type_of.rs | 2 +- src/librustc_typeck/variance/constraints.rs | 2 +- src/librustc_typeck/variance/mod.rs | 2 +- src/librustc_typeck/variance/terms.rs | 2 +- src/librustdoc/clean/mod.rs | 4 ++-- 31 files changed, 67 insertions(+), 70 deletions(-) diff --git a/src/librustc/hir/map/blocks.rs b/src/librustc/hir/map/blocks.rs index 618f9a018d1e7..d9ffe4582e7d7 100644 --- a/src/librustc/hir/map/blocks.rs +++ b/src/librustc/hir/map/blocks.rs @@ -60,7 +60,7 @@ impl MaybeFnLike for hir::ImplItem<'_> { impl MaybeFnLike for hir::TraitItem<'_> { fn is_fn_like(&self) -> bool { match self.kind { - hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true, + hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => true, _ => false, } } @@ -239,7 +239,7 @@ impl<'a> FnLikeNode<'a> { _ => bug!("item FnLikeNode that is not fn-like"), }, Node::TraitItem(ti) => match ti.kind { - hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => { + hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => { method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs) } _ => bug!("trait method FnLikeNode that is not fn-like"), diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 2374d47ae8ee7..9d2cc1877e407 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -51,7 +51,7 @@ impl<'hir> Entry<'hir> { }, Node::TraitItem(ref item) => match item.kind { - TraitItemKind::Method(ref sig, _) => Some(&sig.decl), + TraitItemKind::Fn(ref sig, _) => Some(&sig.decl), _ => None, }, @@ -77,7 +77,7 @@ impl<'hir> Entry<'hir> { }, Node::TraitItem(item) => match &item.kind { - TraitItemKind::Method(sig, _) => Some(sig), + TraitItemKind::Fn(sig, _) => Some(sig), _ => None, }, @@ -101,7 +101,7 @@ impl<'hir> Entry<'hir> { Node::TraitItem(item) => match item.kind { TraitItemKind::Const(_, Some(body)) - | TraitItemKind::Method(_, TraitMethod::Provided(body)) => Some(body), + | TraitItemKind::Fn(_, TraitMethod::Provided(body)) => Some(body), _ => None, }, @@ -326,7 +326,7 @@ impl<'hir> Map<'hir> { }, Node::TraitItem(item) => match item.kind { TraitItemKind::Const(..) => DefKind::AssocConst, - TraitItemKind::Method(..) => DefKind::AssocFn, + TraitItemKind::Fn(..) => DefKind::AssocFn, TraitItemKind::Type(..) => DefKind::AssocTy, }, Node::ImplItem(item) => match item.kind { @@ -473,7 +473,7 @@ impl<'hir> Map<'hir> { | Node::AnonConst(_) => BodyOwnerKind::Const, Node::Ctor(..) | Node::Item(&Item { kind: ItemKind::Fn(..), .. }) - | Node::TraitItem(&TraitItem { kind: TraitItemKind::Method(..), .. }) + | Node::TraitItem(&TraitItem { kind: TraitItemKind::Fn(..), .. }) | Node::ImplItem(&ImplItem { kind: ImplItemKind::Method(..), .. }) => BodyOwnerKind::Fn, Node::Item(&Item { kind: ItemKind::Static(_, m, _), .. }) => BodyOwnerKind::Static(m), Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => BodyOwnerKind::Closure, @@ -801,7 +801,7 @@ impl<'hir> Map<'hir> { _ => false, }, Node::TraitItem(ti) => match ti.kind { - TraitItemKind::Method(..) => true, + TraitItemKind::Fn(..) => true, _ => false, }, Node::ImplItem(ii) => match ii.kind { @@ -1312,7 +1312,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String { Some(Node::TraitItem(ti)) => { let kind = match ti.kind { TraitItemKind::Const(..) => "assoc constant", - TraitItemKind::Method(..) => "trait method", + TraitItemKind::Fn(..) => "trait method", TraitItemKind::Type(..) => "assoc type", }; diff --git a/src/librustc_ast_lowering/item.rs b/src/librustc_ast_lowering/item.rs index 13148d97a67f3..f732f645dc07d 100644 --- a/src/librustc_ast_lowering/item.rs +++ b/src/librustc_ast_lowering/item.rs @@ -767,13 +767,13 @@ impl<'hir> LoweringContext<'_, 'hir> { let names = self.lower_fn_params_to_names(&sig.decl); let (generics, sig) = self.lower_method_sig(generics, sig, trait_item_def_id, false, None); - (generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Required(names))) + (generics, hir::TraitItemKind::Fn(sig, hir::TraitMethod::Required(names))) } AssocItemKind::Fn(_, ref sig, ref generics, Some(ref body)) => { let body_id = self.lower_fn_body_block(i.span, &sig.decl, Some(body)); let (generics, sig) = self.lower_method_sig(generics, sig, trait_item_def_id, false, None); - (generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Provided(body_id))) + (generics, hir::TraitItemKind::Fn(sig, hir::TraitMethod::Provided(body_id))) } AssocItemKind::TyAlias(_, ref generics, ref bounds, ref default) => { let ty = default.as_ref().map(|x| self.lower_ty(x, ImplTraitContext::disallowed())); diff --git a/src/librustc_hir/hir.rs b/src/librustc_hir/hir.rs index f948e22e84b10..5a83c65204cc4 100644 --- a/src/librustc_hir/hir.rs +++ b/src/librustc_hir/hir.rs @@ -1863,8 +1863,8 @@ pub enum TraitMethod<'hir> { pub enum TraitItemKind<'hir> { /// An associated constant with an optional value (otherwise `impl`s must contain a value). Const(&'hir Ty<'hir>, Option), - /// A method with an optional body. - Method(FnSig<'hir>, TraitMethod<'hir>), + /// An associated function with an optional body. + Fn(FnSig<'hir>, TraitMethod<'hir>), /// An associated type with (possibly empty) bounds and optional concrete /// type. Type(GenericBounds<'hir>, Option<&'hir Ty<'hir>>), @@ -2699,7 +2699,7 @@ impl Node<'_> { pub fn fn_decl(&self) -> Option<&FnDecl<'_>> { match self { - Node::TraitItem(TraitItem { kind: TraitItemKind::Method(fn_sig, _), .. }) + Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. }) | Node::ImplItem(ImplItem { kind: ImplItemKind::Method(fn_sig, _), .. }) | Node::Item(Item { kind: ItemKind::Fn(fn_sig, _, _), .. }) => Some(fn_sig.decl), Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_decl, _, _), .. }) => { diff --git a/src/librustc_hir/intravisit.rs b/src/librustc_hir/intravisit.rs index 45257b04d7907..e92192c8b1f72 100644 --- a/src/librustc_hir/intravisit.rs +++ b/src/librustc_hir/intravisit.rs @@ -911,14 +911,14 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai visitor.visit_ty(ty); walk_list!(visitor, visit_nested_body, default); } - TraitItemKind::Method(ref sig, TraitMethod::Required(param_names)) => { + TraitItemKind::Fn(ref sig, TraitMethod::Required(param_names)) => { visitor.visit_id(trait_item.hir_id); visitor.visit_fn_decl(&sig.decl); for ¶m_name in param_names { visitor.visit_ident(param_name); } } - TraitItemKind::Method(ref sig, TraitMethod::Provided(body_id)) => { + TraitItemKind::Fn(ref sig, TraitMethod::Provided(body_id)) => { visitor.visit_fn( FnKind::Method(trait_item.ident, sig, None, &trait_item.attrs), &sig.decl, diff --git a/src/librustc_hir/print.rs b/src/librustc_hir/print.rs index 8cbbef959ce75..7738548dadef2 100644 --- a/src/librustc_hir/print.rs +++ b/src/librustc_hir/print.rs @@ -886,13 +886,13 @@ impl<'a> State<'a> { Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Inherited }; self.print_associated_const(ti.ident, &ty, default, &vis); } - hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Required(ref arg_names)) => { + hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Required(ref arg_names)) => { let vis = Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Inherited }; self.print_method_sig(ti.ident, sig, &ti.generics, &vis, arg_names, None); self.s.word(";"); } - hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => { + hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => { let vis = Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Inherited }; self.head(""); diff --git a/src/librustc_hir/target.rs b/src/librustc_hir/target.rs index 501976fc3cb39..b7bc555d7b410 100644 --- a/src/librustc_hir/target.rs +++ b/src/librustc_hir/target.rs @@ -105,10 +105,10 @@ impl Target { pub fn from_trait_item(trait_item: &TraitItem<'_>) -> Target { match trait_item.kind { TraitItemKind::Const(..) => Target::AssocConst, - TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => { + TraitItemKind::Fn(_, hir::TraitMethod::Required(_)) => { Target::Method(MethodKind::Trait { body: false }) } - TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => { + TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => { Target::Method(MethodKind::Trait { body: true }) } TraitItemKind::Type(..) => Target::AssocTy, diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index f304292d922e5..86c3fbcf8c7c1 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -328,7 +328,7 @@ impl DirtyCleanVisitor<'tcx> { } } HirNode::TraitItem(item) => match item.kind { - TraitItemKind::Method(..) => ("Node::TraitItem", LABELS_FN_IN_TRAIT), + TraitItemKind::Fn(..) => ("Node::TraitItem", LABELS_FN_IN_TRAIT), TraitItemKind::Const(..) => ("NodeTraitConst", LABELS_CONST_IN_TRAIT), TraitItemKind::Type(..) => ("NodeTraitType", LABELS_CONST_IN_TRAIT), }, diff --git a/src/librustc_infer/infer/error_reporting/mod.rs b/src/librustc_infer/infer/error_reporting/mod.rs index bd133738db7ab..9185c46702308 100644 --- a/src/librustc_infer/infer/error_reporting/mod.rs +++ b/src/librustc_infer/infer/error_reporting/mod.rs @@ -269,7 +269,7 @@ fn item_scope_tag(item: &hir::Item<'_>) -> &'static str { fn trait_item_scope_tag(item: &hir::TraitItem<'_>) -> &'static str { match item.kind { - hir::TraitItemKind::Method(..) => "method body", + hir::TraitItemKind::Fn(..) => "method body", hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => "associated item", } } diff --git a/src/librustc_infer/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc_infer/infer/error_reporting/nice_region_error/find_anon_type.rs index 2ae7f4cc04f98..7346cb0a03393 100644 --- a/src/librustc_infer/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc_infer/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -33,7 +33,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { let fndecl = match self.tcx().hir().get(hir_id) { Node::Item(&hir::Item { kind: hir::ItemKind::Fn(ref m, ..), .. }) | Node::TraitItem(&hir::TraitItem { - kind: hir::TraitItemKind::Method(ref m, ..), + kind: hir::TraitItemKind::Fn(ref m, ..), .. }) | Node::ImplItem(&hir::ImplItem { diff --git a/src/librustc_infer/traits/error_reporting/on_unimplemented.rs b/src/librustc_infer/traits/error_reporting/on_unimplemented.rs index 87c1107bd427d..eb34a4875961c 100644 --- a/src/librustc_infer/traits/error_reporting/on_unimplemented.rs +++ b/src/librustc_infer/traits/error_reporting/on_unimplemented.rs @@ -70,7 +70,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { }) } hir::Node::TraitItem(hir::TraitItem { - kind: hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)), + kind: hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(body_id)), .. }) => self.describe_generator(*body_id).or_else(|| Some("a trait method")), hir::Node::ImplItem(hir::ImplItem { diff --git a/src/librustc_infer/traits/error_reporting/suggestions.rs b/src/librustc_infer/traits/error_reporting/suggestions.rs index ed6cfa51cdf18..e8575cd2c47e1 100644 --- a/src/librustc_infer/traits/error_reporting/suggestions.rs +++ b/src/librustc_infer/traits/error_reporting/suggestions.rs @@ -62,7 +62,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { match node { hir::Node::TraitItem(hir::TraitItem { generics, - kind: hir::TraitItemKind::Method(..), + kind: hir::TraitItemKind::Fn(..), .. }) if param_ty && self_ty == self.tcx.types.self_param => { // Restricting `Self` for a single method. @@ -73,7 +73,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, generics, _), .. }) | hir::Node::TraitItem(hir::TraitItem { generics, - kind: hir::TraitItemKind::Method(..), + kind: hir::TraitItemKind::Fn(..), .. }) | hir::Node::ImplItem(hir::ImplItem { @@ -807,7 +807,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { }) | Node::TraitItem(&hir::TraitItem { span, - kind: hir::TraitItemKind::Method(ref sig, _), + kind: hir::TraitItemKind::Fn(ref sig, _), .. }) => ( self.tcx.sess.source_map().def_span(span), diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 3eecd2a54e33e..c8bffc4d445a6 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -465,7 +465,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { let desc = match trait_item.kind { hir::TraitItemKind::Const(..) => "an associated constant", - hir::TraitItemKind::Method(..) => "a trait method", + hir::TraitItemKind::Fn(..) => "a trait method", hir::TraitItemKind::Type(..) => "an associated type", }; diff --git a/src/librustc_lint/nonstandard_style.rs b/src/librustc_lint/nonstandard_style.rs index b0560dc9fdf9c..37fefe680d7d2 100644 --- a/src/librustc_lint/nonstandard_style.rs +++ b/src/librustc_lint/nonstandard_style.rs @@ -343,7 +343,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase { } fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::TraitItem<'_>) { - if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(pnames)) = item.kind { + if let hir::TraitItemKind::Fn(_, hir::TraitMethod::Required(pnames)) = item.kind { self.check_snake_case(cx, "trait method", &item.ident); for param_name in pnames { self.check_snake_case(cx, "variable", param_name); diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs index ea0cc2f0c8bf2..b89cd0792b893 100644 --- a/src/librustc_metadata/rmeta/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -805,7 +805,7 @@ impl EncodeContext<'tcx> { ) } ty::AssocKind::Method => { - let fn_data = if let hir::TraitItemKind::Method(m_sig, m) = &ast_item.kind { + let fn_data = if let hir::TraitItemKind::Fn(m_sig, m) = &ast_item.kind { let param_names = match *m { hir::TraitMethod::Required(ref names) => { self.encode_fn_param_names(names) diff --git a/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs b/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs index d91f6edc9800c..7ebc164e49c56 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs @@ -478,7 +478,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { })) | Some(hir::Node::TraitItem(hir::TraitItem { ident, - kind: hir::TraitItemKind::Method(sig, _), + kind: hir::TraitItemKind::Fn(sig, _), .. })) | Some(hir::Node::ImplItem(hir::ImplItem { @@ -520,7 +520,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { hir::Node::Item(hir::Item { ident, kind: hir::ItemKind::Fn(sig, ..), .. }) | hir::Node::TraitItem(hir::TraitItem { ident, - kind: hir::TraitItemKind::Method(sig, _), + kind: hir::TraitItemKind::Fn(sig, _), .. }) | hir::Node::ImplItem(hir::ImplItem { diff --git a/src/librustc_mir_build/build/mod.rs b/src/librustc_mir_build/build/mod.rs index 830877f713e4b..4cd1efe4ef912 100644 --- a/src/librustc_mir_build/build/mod.rs +++ b/src/librustc_mir_build/build/mod.rs @@ -44,7 +44,7 @@ fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyAndCache<'_> { }) | Node::TraitItem(hir::TraitItem { kind: - hir::TraitItemKind::Method(hir::FnSig { decl, .. }, hir::TraitMethod::Provided(body_id)), + hir::TraitItemKind::Fn(hir::FnSig { decl, .. }, hir::TraitMethod::Provided(body_id)), .. }) => (*body_id, decl.output.span()), Node::Item(hir::Item { kind: hir::ItemKind::Static(ty, _, body_id), .. }) diff --git a/src/librustc_passes/dead.rs b/src/librustc_passes/dead.rs index bcf9fd5a5353f..4a0ffc23365da 100644 --- a/src/librustc_passes/dead.rs +++ b/src/librustc_passes/dead.rs @@ -391,7 +391,7 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> { let trait_item = self.krate.trait_item(trait_item_ref.id); match trait_item.kind { hir::TraitItemKind::Const(_, Some(_)) - | hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => { + | hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => { if has_allow_dead_code_or_lang_attr( self.tcx, trait_item.hir_id, @@ -682,11 +682,11 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> { fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) { match trait_item.kind { hir::TraitItemKind::Const(_, Some(body_id)) - | hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)) => { + | hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(body_id)) => { self.visit_nested_body(body_id) } hir::TraitItemKind::Const(_, None) - | hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) + | hir::TraitItemKind::Fn(_, hir::TraitMethod::Required(_)) | hir::TraitItemKind::Type(..) => {} } } diff --git a/src/librustc_passes/reachable.rs b/src/librustc_passes/reachable.rs index 888f4370dd5e8..79a9f22603042 100644 --- a/src/librustc_passes/reachable.rs +++ b/src/librustc_passes/reachable.rs @@ -162,8 +162,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { }, Some(Node::TraitItem(trait_method)) => match trait_method.kind { hir::TraitItemKind::Const(_, ref default) => default.is_some(), - hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true, - hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) + hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => true, + hir::TraitItemKind::Fn(_, hir::TraitMethod::Required(_)) | hir::TraitItemKind::Type(..) => false, }, Some(Node::ImplItem(impl_item)) => { @@ -278,11 +278,11 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { Node::TraitItem(trait_method) => { match trait_method.kind { hir::TraitItemKind::Const(_, None) - | hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => { + | hir::TraitItemKind::Fn(_, hir::TraitMethod::Required(_)) => { // Keep going, nothing to get exported } hir::TraitItemKind::Const(_, Some(body_id)) - | hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)) => { + | hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(body_id)) => { self.visit_nested_body(body_id); } hir::TraitItemKind::Type(..) => {} diff --git a/src/librustc_resolve/late/lifetimes.rs b/src/librustc_resolve/late/lifetimes.rs index 193b6d75935b2..280acfe8c4872 100644 --- a/src/librustc_resolve/late/lifetimes.rs +++ b/src/librustc_resolve/late/lifetimes.rs @@ -713,7 +713,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { use self::hir::TraitItemKind::*; self.missing_named_lifetime_spots.push((&trait_item.generics).into()); match trait_item.kind { - Method(ref sig, _) => { + Fn(ref sig, _) => { let tcx = self.tcx; self.visit_early_late( Some(tcx.hir().get_parent_item(trait_item.hir_id)), @@ -1816,8 +1816,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { match self.tcx.hir().get(fn_id) { Node::Item(&hir::Item { kind: hir::ItemKind::Fn(..), .. }) | Node::TraitItem(&hir::TraitItem { - kind: hir::TraitItemKind::Method(..), - .. + kind: hir::TraitItemKind::Fn(..), .. }) | Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Method(..), .. @@ -2093,9 +2092,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { // `fn` definitions and methods. Node::Item(&hir::Item { kind: hir::ItemKind::Fn(.., body), .. }) => Some(body), - Node::TraitItem(&hir::TraitItem { - kind: hir::TraitItemKind::Method(_, ref m), .. - }) => { + Node::TraitItem(&hir::TraitItem { kind: hir::TraitItemKind::Fn(_, ref m), .. }) => { if let hir::ItemKind::Trait(.., ref trait_items) = self.tcx.hir().expect_item(self.tcx.hir().get_parent_item(parent)).kind { diff --git a/src/librustc_traits/lowering/environment.rs b/src/librustc_traits/lowering/environment.rs index 0e26e9461f4c3..db392ede432e1 100644 --- a/src/librustc_traits/lowering/environment.rs +++ b/src/librustc_traits/lowering/environment.rs @@ -185,7 +185,7 @@ crate fn environment(tcx: TyCtxt<'_>, def_id: DefId) -> Environment<'_> { let node_kind = match node { Node::TraitItem(item) => match item.kind { - TraitItemKind::Method(..) => NodeKind::Fn, + TraitItemKind::Fn(..) => NodeKind::Fn, _ => NodeKind::Other, }, diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 8b54b5343756a..0c8dec8f8d4a9 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -412,8 +412,8 @@ fn extract_spans_for_error_reporting<'a, 'tcx>( TypeError::Mutability => { if let Some(trait_m_hir_id) = tcx.hir().as_local_hir_id(trait_m.def_id) { let trait_m_iter = match tcx.hir().expect_trait_item(trait_m_hir_id).kind { - TraitItemKind::Method(ref trait_m_sig, _) => trait_m_sig.decl.inputs.iter(), - _ => bug!("{:?} is not a TraitItemKind::Method", trait_m), + TraitItemKind::Fn(ref trait_m_sig, _) => trait_m_sig.decl.inputs.iter(), + _ => bug!("{:?} is not a TraitItemKind::Fn", trait_m), }; impl_m_iter @@ -440,10 +440,10 @@ fn extract_spans_for_error_reporting<'a, 'tcx>( if let Some(trait_m_hir_id) = tcx.hir().as_local_hir_id(trait_m.def_id) { let (trait_m_output, trait_m_iter) = match tcx.hir().expect_trait_item(trait_m_hir_id).kind { - TraitItemKind::Method(ref trait_m_sig, _) => { + TraitItemKind::Fn(ref trait_m_sig, _) => { (&trait_m_sig.decl.output, trait_m_sig.decl.inputs.iter()) } - _ => bug!("{:?} is not a TraitItemKind::Method", trait_m), + _ => bug!("{:?} is not a TraitItemKind::Fn", trait_m), }; let impl_iter = impl_sig.inputs().iter(); @@ -708,7 +708,7 @@ fn compare_number_of_method_arguments<'tcx>( let trait_m_hir_id = tcx.hir().as_local_hir_id(trait_m.def_id); let trait_span = if let Some(trait_id) = trait_m_hir_id { match tcx.hir().expect_trait_item(trait_id).kind { - TraitItemKind::Method(ref trait_m_sig, _) => { + TraitItemKind::Fn(ref trait_m_sig, _) => { let pos = if trait_number_args > 0 { trait_number_args - 1 } else { 0 }; if let Some(arg) = trait_m_sig.decl.inputs.get(pos) { Some(if pos == 0 { diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 95faa353e9b65..9e3b4a7be72bb 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -930,7 +930,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let ty::AssocKind::Method = item.kind { let id = self.tcx.hir().as_local_hir_id(item.def_id); if let Some(hir::Node::TraitItem(hir::TraitItem { - kind: hir::TraitItemKind::Method(fn_sig, method), + kind: hir::TraitItemKind::Fn(fn_sig, method), .. })) = id.map(|id| self.tcx.hir().get(id)) { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index fd5cac5b24bf1..3388a70b4cfd0 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -811,7 +811,7 @@ fn primary_body_of( }, Node::TraitItem(item) => match item.kind { hir::TraitItemKind::Const(ref ty, Some(body)) => Some((body, Some(ty), None, None)), - hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => { + hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => { Some((body, None, Some(&sig.header), Some(&sig.decl))) } _ => None, @@ -1733,7 +1733,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) { for item in items.iter() { let item = tcx.hir().trait_item(item.id); - if let hir::TraitItemKind::Method(sig, _) = &item.kind { + if let hir::TraitItemKind::Fn(sig, _) = &item.kind { let abi = sig.header.abi; fn_maybe_err(tcx, item.ident.span, abi); } @@ -4769,7 +4769,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } Node::TraitItem(&hir::TraitItem { ident, - kind: hir::TraitItemKind::Method(ref sig, ..), + kind: hir::TraitItemKind::Fn(ref sig, ..), .. }) => Some((&sig.decl, ident, true)), Node::ImplItem(&hir::ImplItem { @@ -4863,7 +4863,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .. })) | Some(Node::TraitItem(hir::TraitItem { - kind: hir::TraitItemKind::Method(.., hir::TraitMethod::Provided(body_id)), + kind: hir::TraitItemKind::Fn(.., hir::TraitMethod::Provided(body_id)), .. })) => { let body = hir.body(*body_id); @@ -4934,7 +4934,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .join(", ") } Some(Node::TraitItem(hir::TraitItem { - kind: hir::TraitItemKind::Method(.., hir::TraitMethod::Required(idents)), + kind: hir::TraitItemKind::Fn(.., hir::TraitMethod::Required(idents)), .. })) => { sugg_call = idents diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index e8e34a4e8f079..335b4a2850116 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -173,7 +173,7 @@ pub fn check_trait_item(tcx: TyCtxt<'_>, def_id: DefId) { let trait_item = tcx.hir().expect_trait_item(hir_id); let method_sig = match trait_item.kind { - hir::TraitItemKind::Method(ref sig, _) => Some(sig), + hir::TraitItemKind::Fn(ref sig, _) => Some(sig), _ => None, }; check_object_unsafe_self_trait_by_name(tcx, &trait_item); @@ -207,7 +207,7 @@ fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem { trait_should_be_self.push(ty.span) } - hir::TraitItemKind::Method(sig, _) => { + hir::TraitItemKind::Fn(sig, _) => { for ty in sig.decl.inputs { if could_be_self(trait_def_id, ty) { trait_should_be_self.push(ty.span); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 2dad3d1d6d708..d6262b352480d 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -715,7 +715,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) { tcx.generics_of(def_id); match trait_item.kind { - hir::TraitItemKind::Method(..) => { + hir::TraitItemKind::Fn(..) => { tcx.type_of(def_id); tcx.fn_sig(def_id); } @@ -1121,7 +1121,7 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option match item.kind { - hir::TraitItemKind::Method(ref sig, _) => { + hir::TraitItemKind::Fn(ref sig, _) => { has_late_bound_regions(tcx, &item.generics, &sig.decl) } _ => None, @@ -1437,7 +1437,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { match tcx.hir().get(hir_id) { TraitItem(hir::TraitItem { - kind: TraitItemKind::Method(sig, TraitMethod::Provided(_)), + kind: TraitItemKind::Fn(sig, TraitMethod::Provided(_)), ident, generics, .. @@ -1474,7 +1474,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { } TraitItem(hir::TraitItem { - kind: TraitItemKind::Method(FnSig { header, decl }, _), + kind: TraitItemKind::Fn(FnSig { header, decl }, _), ident, generics, .. diff --git a/src/librustc_typeck/collect/type_of.rs b/src/librustc_typeck/collect/type_of.rs index ec87112b7a8e0..815235adc7175 100644 --- a/src/librustc_typeck/collect/type_of.rs +++ b/src/librustc_typeck/collect/type_of.rs @@ -27,7 +27,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { match tcx.hir().get(hir_id) { Node::TraitItem(item) => match item.kind { - TraitItemKind::Method(..) => { + TraitItemKind::Fn(..) => { let substs = InternalSubsts::identity_for_item(tcx, def_id); tcx.mk_fn_def(def_id, substs) } diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 6f5caea250b07..fc3b7201a1e63 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -105,7 +105,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> { } fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) { - if let hir::TraitItemKind::Method(..) = trait_item.kind { + if let hir::TraitItemKind::Fn(..) = trait_item.kind { self.visit_node_helper(trait_item.hir_id); } } diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index ddde11b38448b..412b90a9acffa 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -54,7 +54,7 @@ fn variances_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[ty::Variance] { }, Node::TraitItem(item) => match item.kind { - hir::TraitItemKind::Method(..) => {} + hir::TraitItemKind::Fn(..) => {} _ => unsupported(), }, diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index dd593a6abb4fe..f79f8c4bb9510 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -164,7 +164,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> { } fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) { - if let hir::TraitItemKind::Method(..) = trait_item.kind { + if let hir::TraitItemKind::Fn(..) = trait_item.kind { self.add_inferreds_for_item(trait_item.hir_id); } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 7c845a9b66bbd..569faf73a2114 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1084,10 +1084,10 @@ impl Clean for hir::TraitItem<'_> { hir::TraitItemKind::Const(ref ty, default) => { AssocConstItem(ty.clean(cx), default.map(|e| print_const_expr(cx, e))) } - hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => { + hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => { MethodItem((sig, &self.generics, body, None).clean(cx)) } - hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Required(ref names)) => { + hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Required(ref names)) => { let (generics, decl) = enter_impl_trait(cx, || { (self.generics.clean(cx), (&*sig.decl, &names[..]).clean(cx)) });