Skip to content

Commit b2ad1ab

Browse files
committed
More Method->Fn renaming
1 parent 54b7d21 commit b2ad1ab

File tree

38 files changed

+103
-108
lines changed

38 files changed

+103
-108
lines changed

src/librustc/hir/map/blocks.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl MaybeFnLike for hir::Item<'_> {
5151
impl MaybeFnLike for hir::ImplItem<'_> {
5252
fn is_fn_like(&self) -> bool {
5353
match self.kind {
54-
hir::ImplItemKind::Method(..) => true,
54+
hir::ImplItemKind::Fn(..) => true,
5555
_ => false,
5656
}
5757
}
@@ -60,7 +60,7 @@ impl MaybeFnLike for hir::ImplItem<'_> {
6060
impl MaybeFnLike for hir::TraitItem<'_> {
6161
fn is_fn_like(&self) -> bool {
6262
match self.kind {
63-
hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => true,
63+
hir::TraitItemKind::Fn(_, hir::TraitFn::Provided(_)) => true,
6464
_ => false,
6565
}
6666
}
@@ -239,13 +239,13 @@ impl<'a> FnLikeNode<'a> {
239239
_ => bug!("item FnLikeNode that is not fn-like"),
240240
},
241241
Node::TraitItem(ti) => match ti.kind {
242-
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => {
242+
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(body)) => {
243243
method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs)
244244
}
245245
_ => bug!("trait method FnLikeNode that is not fn-like"),
246246
},
247247
Node::ImplItem(ii) => match ii.kind {
248-
hir::ImplItemKind::Method(ref sig, body) => {
248+
hir::ImplItemKind::Fn(ref sig, body) => {
249249
method(ii.hir_id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs)
250250
}
251251
_ => bug!("impl method FnLikeNode that is not fn-like"),

src/librustc/hir/map/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<'hir> Entry<'hir> {
5656
},
5757

5858
Node::ImplItem(ref item) => match item.kind {
59-
ImplItemKind::Method(ref sig, _) => Some(&sig.decl),
59+
ImplItemKind::Fn(ref sig, _) => Some(&sig.decl),
6060
_ => None,
6161
},
6262

@@ -82,7 +82,7 @@ impl<'hir> Entry<'hir> {
8282
},
8383

8484
Node::ImplItem(item) => match &item.kind {
85-
ImplItemKind::Method(sig, _) => Some(sig),
85+
ImplItemKind::Fn(sig, _) => Some(sig),
8686
_ => None,
8787
},
8888

@@ -101,12 +101,12 @@ impl<'hir> Entry<'hir> {
101101

102102
Node::TraitItem(item) => match item.kind {
103103
TraitItemKind::Const(_, Some(body))
104-
| TraitItemKind::Fn(_, TraitMethod::Provided(body)) => Some(body),
104+
| TraitItemKind::Fn(_, TraitFn::Provided(body)) => Some(body),
105105
_ => None,
106106
},
107107

108108
Node::ImplItem(item) => match item.kind {
109-
ImplItemKind::Const(_, body) | ImplItemKind::Method(_, body) => Some(body),
109+
ImplItemKind::Const(_, body) | ImplItemKind::Fn(_, body) => Some(body),
110110
_ => None,
111111
},
112112

@@ -331,7 +331,7 @@ impl<'hir> Map<'hir> {
331331
},
332332
Node::ImplItem(item) => match item.kind {
333333
ImplItemKind::Const(..) => DefKind::AssocConst,
334-
ImplItemKind::Method(..) => DefKind::AssocFn,
334+
ImplItemKind::Fn(..) => DefKind::AssocFn,
335335
ImplItemKind::TyAlias(..) => DefKind::AssocTy,
336336
ImplItemKind::OpaqueTy(..) => DefKind::AssocOpaqueTy,
337337
},
@@ -473,7 +473,7 @@ impl<'hir> Map<'hir> {
473473
Node::Ctor(..)
474474
| Node::Item(&Item { kind: ItemKind::Fn(..), .. })
475475
| Node::TraitItem(&TraitItem { kind: TraitItemKind::Fn(..), .. })
476-
| Node::ImplItem(&ImplItem { kind: ImplItemKind::Method(..), .. }) => BodyOwnerKind::Fn,
476+
| Node::ImplItem(&ImplItem { kind: ImplItemKind::Fn(..), .. }) => BodyOwnerKind::Fn,
477477
Node::Item(&Item { kind: ItemKind::Static(_, m, _), .. }) => BodyOwnerKind::Static(m),
478478
Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => BodyOwnerKind::Closure,
479479
node => bug!("{:#?} is not a body node", node),
@@ -804,7 +804,7 @@ impl<'hir> Map<'hir> {
804804
_ => false,
805805
},
806806
Node::ImplItem(ii) => match ii.kind {
807-
ImplItemKind::Method(..) => true,
807+
ImplItemKind::Fn(..) => true,
808808
_ => false,
809809
},
810810
Node::Block(_) => true,
@@ -1300,7 +1300,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
13001300
ImplItemKind::Const(..) => {
13011301
format!("assoc const {} in {}{}", ii.ident, path_str(), id_str)
13021302
}
1303-
ImplItemKind::Method(..) => format!("method {} in {}{}", ii.ident, path_str(), id_str),
1303+
ImplItemKind::Fn(..) => format!("method {} in {}{}", ii.ident, path_str(), id_str),
13041304
ImplItemKind::TyAlias(_) => {
13051305
format!("assoc type {} in {}{}", ii.ident, path_str(), id_str)
13061306
}

src/librustc_ast_lowering/item.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -761,13 +761,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
761761
let names = self.lower_fn_params_to_names(&sig.decl);
762762
let (generics, sig) =
763763
self.lower_method_sig(generics, sig, trait_item_def_id, false, None);
764-
(generics, hir::TraitItemKind::Fn(sig, hir::TraitMethod::Required(names)))
764+
(generics, hir::TraitItemKind::Fn(sig, hir::TraitFn::Required(names)))
765765
}
766766
AssocItemKind::Fn(_, ref sig, ref generics, Some(ref body)) => {
767767
let body_id = self.lower_fn_body_block(i.span, &sig.decl, Some(body));
768768
let (generics, sig) =
769769
self.lower_method_sig(generics, sig, trait_item_def_id, false, None);
770-
(generics, hir::TraitItemKind::Fn(sig, hir::TraitMethod::Provided(body_id)))
770+
(generics, hir::TraitItemKind::Fn(sig, hir::TraitFn::Provided(body_id)))
771771
}
772772
AssocItemKind::TyAlias(_, ref generics, ref bounds, ref default) => {
773773
let ty = default.as_ref().map(|x| self.lower_ty(x, ImplTraitContext::disallowed()));
@@ -838,7 +838,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
838838
asyncness.opt_return_id(),
839839
);
840840

841-
(generics, hir::ImplItemKind::Method(sig, body_id))
841+
(generics, hir::ImplItemKind::Fn(sig, body_id))
842842
}
843843
AssocItemKind::TyAlias(_, generics, _, ty) => {
844844
let generics = self.lower_generics(generics, ImplTraitContext::disallowed());

src/librustc_codegen_ssa/back/symbol_export.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn reachable_non_generics_provider(
8888
// Only consider nodes that actually have exported symbols.
8989
Node::Item(&hir::Item { kind: hir::ItemKind::Static(..), .. })
9090
| Node::Item(&hir::Item { kind: hir::ItemKind::Fn(..), .. })
91-
| Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Method(..), .. }) => {
91+
| Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Fn(..), .. }) => {
9292
let def_id = tcx.hir().local_def_id(hir_id);
9393
let generics = tcx.generics_of(def_id);
9494
if !generics.requires_monomorphization(tcx) &&

src/librustc_hir/hir.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,7 @@ pub struct TraitItem<'hir> {
18501850

18511851
/// Represents a trait method's body (or just argument names).
18521852
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
1853-
pub enum TraitMethod<'hir> {
1853+
pub enum TraitFn<'hir> {
18541854
/// No default body in the trait, just a signature.
18551855
Required(&'hir [Ident]),
18561856

@@ -1864,7 +1864,7 @@ pub enum TraitItemKind<'hir> {
18641864
/// An associated constant with an optional value (otherwise `impl`s must contain a value).
18651865
Const(&'hir Ty<'hir>, Option<BodyId>),
18661866
/// An associated function with an optional body.
1867-
Fn(FnSig<'hir>, TraitMethod<'hir>),
1867+
Fn(FnSig<'hir>, TraitFn<'hir>),
18681868
/// An associated type with (possibly empty) bounds and optional concrete
18691869
/// type.
18701870
Type(GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
@@ -1898,7 +1898,7 @@ pub enum ImplItemKind<'hir> {
18981898
/// of the expression.
18991899
Const(&'hir Ty<'hir>, BodyId),
19001900
/// A method implementation with the given signature and body.
1901-
Method(FnSig<'hir>, BodyId),
1901+
Fn(FnSig<'hir>, BodyId),
19021902
/// An associated type.
19031903
TyAlias(&'hir Ty<'hir>),
19041904
/// An associated `type = impl Trait`.
@@ -1909,7 +1909,7 @@ impl ImplItemKind<'_> {
19091909
pub fn namespace(&self) -> Namespace {
19101910
match self {
19111911
ImplItemKind::OpaqueTy(..) | ImplItemKind::TyAlias(..) => Namespace::TypeNS,
1912-
ImplItemKind::Const(..) | ImplItemKind::Method(..) => Namespace::ValueNS,
1912+
ImplItemKind::Const(..) | ImplItemKind::Fn(..) => Namespace::ValueNS,
19131913
}
19141914
}
19151915
}
@@ -2700,7 +2700,7 @@ impl Node<'_> {
27002700
pub fn fn_decl(&self) -> Option<&FnDecl<'_>> {
27012701
match self {
27022702
Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
2703-
| Node::ImplItem(ImplItem { kind: ImplItemKind::Method(fn_sig, _), .. })
2703+
| Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
27042704
| Node::Item(Item { kind: ItemKind::Fn(fn_sig, _, _), .. }) => Some(fn_sig.decl),
27052705
Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_decl, _, _), .. }) => {
27062706
Some(fn_decl)

src/librustc_hir/intravisit.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -911,14 +911,14 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
911911
visitor.visit_ty(ty);
912912
walk_list!(visitor, visit_nested_body, default);
913913
}
914-
TraitItemKind::Fn(ref sig, TraitMethod::Required(param_names)) => {
914+
TraitItemKind::Fn(ref sig, TraitFn::Required(param_names)) => {
915915
visitor.visit_id(trait_item.hir_id);
916916
visitor.visit_fn_decl(&sig.decl);
917917
for &param_name in param_names {
918918
visitor.visit_ident(param_name);
919919
}
920920
}
921-
TraitItemKind::Fn(ref sig, TraitMethod::Provided(body_id)) => {
921+
TraitItemKind::Fn(ref sig, TraitFn::Provided(body_id)) => {
922922
visitor.visit_fn(
923923
FnKind::Method(trait_item.ident, sig, None, &trait_item.attrs),
924924
&sig.decl,
@@ -968,7 +968,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
968968
visitor.visit_ty(ty);
969969
visitor.visit_nested_body(body);
970970
}
971-
ImplItemKind::Method(ref sig, body_id) => {
971+
ImplItemKind::Fn(ref sig, body_id) => {
972972
visitor.visit_fn(
973973
FnKind::Method(impl_item.ident, sig, Some(&impl_item.vis), &impl_item.attrs),
974974
&sig.decl,

src/librustc_hir/print.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -886,13 +886,13 @@ impl<'a> State<'a> {
886886
Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Inherited };
887887
self.print_associated_const(ti.ident, &ty, default, &vis);
888888
}
889-
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Required(ref arg_names)) => {
889+
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Required(ref arg_names)) => {
890890
let vis =
891891
Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Inherited };
892892
self.print_method_sig(ti.ident, sig, &ti.generics, &vis, arg_names, None);
893893
self.s.word(";");
894894
}
895-
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => {
895+
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(body)) => {
896896
let vis =
897897
Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Inherited };
898898
self.head("");
@@ -925,7 +925,7 @@ impl<'a> State<'a> {
925925
hir::ImplItemKind::Const(ref ty, expr) => {
926926
self.print_associated_const(ii.ident, &ty, Some(expr), &ii.vis);
927927
}
928-
hir::ImplItemKind::Method(ref sig, body) => {
928+
hir::ImplItemKind::Fn(ref sig, body) => {
929929
self.head("");
930930
self.print_method_sig(ii.ident, sig, &ii.generics, &ii.vis, &[], Some(body));
931931
self.nbsp();

src/librustc_hir/target.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ impl Target {
105105
pub fn from_trait_item(trait_item: &TraitItem<'_>) -> Target {
106106
match trait_item.kind {
107107
TraitItemKind::Const(..) => Target::AssocConst,
108-
TraitItemKind::Fn(_, hir::TraitMethod::Required(_)) => {
108+
TraitItemKind::Fn(_, hir::TraitFn::Required(_)) => {
109109
Target::Method(MethodKind::Trait { body: false })
110110
}
111-
TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => {
111+
TraitItemKind::Fn(_, hir::TraitFn::Provided(_)) => {
112112
Target::Method(MethodKind::Trait { body: true })
113113
}
114114
TraitItemKind::Type(..) => Target::AssocTy,

src/librustc_incremental/persist/dirty_clean.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ impl DirtyCleanVisitor<'tcx> {
333333
TraitItemKind::Type(..) => ("NodeTraitType", LABELS_CONST_IN_TRAIT),
334334
},
335335
HirNode::ImplItem(item) => match item.kind {
336-
ImplItemKind::Method(..) => ("Node::ImplItem", LABELS_FN_IN_IMPL),
336+
ImplItemKind::Fn(..) => ("Node::ImplItem", LABELS_FN_IN_IMPL),
337337
ImplItemKind::Const(..) => ("NodeImplConst", LABELS_CONST_IN_IMPL),
338338
ImplItemKind::TyAlias(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),
339339
ImplItemKind::OpaqueTy(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),

src/librustc_infer/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ fn trait_item_scope_tag(item: &hir::TraitItem<'_>) -> &'static str {
276276

277277
fn impl_item_scope_tag(item: &hir::ImplItem<'_>) -> &'static str {
278278
match item.kind {
279-
hir::ImplItemKind::Method(..) => "method body",
279+
hir::ImplItemKind::Fn(..) => "method body",
280280
hir::ImplItemKind::Const(..)
281281
| hir::ImplItemKind::OpaqueTy(..)
282282
| hir::ImplItemKind::TyAlias(..) => "associated item",

src/librustc_infer/infer/error_reporting/nice_region_error/find_anon_type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
3737
..
3838
})
3939
| Node::ImplItem(&hir::ImplItem {
40-
kind: hir::ImplItemKind::Method(ref m, ..),
40+
kind: hir::ImplItemKind::Fn(ref m, ..),
4141
..
4242
}) => &m.decl,
4343
_ => return None,

src/librustc_infer/traits/error_reporting/on_unimplemented.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
7070
})
7171
}
7272
hir::Node::TraitItem(hir::TraitItem {
73-
kind: hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(body_id)),
73+
kind: hir::TraitItemKind::Fn(_, hir::TraitFn::Provided(body_id)),
7474
..
7575
}) => self.describe_generator(*body_id).or_else(|| Some("a trait method")),
7676
hir::Node::ImplItem(hir::ImplItem {
77-
kind: hir::ImplItemKind::Method(sig, body_id),
77+
kind: hir::ImplItemKind::Fn(sig, body_id),
7878
..
7979
}) => self.describe_generator(*body_id).or_else(|| {
8080
Some(if let hir::FnHeader { asyncness: hir::IsAsync::Async, .. } = sig.header {

src/librustc_infer/traits/error_reporting/suggestions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
7878
})
7979
| hir::Node::ImplItem(hir::ImplItem {
8080
generics,
81-
kind: hir::ImplItemKind::Method(..),
81+
kind: hir::ImplItemKind::Fn(..),
8282
..
8383
})
8484
| hir::Node::Item(hir::Item {
@@ -798,7 +798,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
798798
Node::Item(&hir::Item { span, kind: hir::ItemKind::Fn(ref sig, ..), .. })
799799
| Node::ImplItem(&hir::ImplItem {
800800
span,
801-
kind: hir::ImplItemKind::Method(ref sig, _),
801+
kind: hir::ImplItemKind::Fn(ref sig, _),
802802
..
803803
})
804804
| Node::TraitItem(&hir::TraitItem {

src/librustc_lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
486486

487487
let desc = match impl_item.kind {
488488
hir::ImplItemKind::Const(..) => "an associated constant",
489-
hir::ImplItemKind::Method(..) => "a method",
489+
hir::ImplItemKind::Fn(..) => "a method",
490490
hir::ImplItemKind::TyAlias(_) => "an associated type",
491491
hir::ImplItemKind::OpaqueTy(_) => "an associated `impl Trait` type",
492492
};

src/librustc_lint/nonstandard_style.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
343343
}
344344

345345
fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::TraitItem<'_>) {
346-
if let hir::TraitItemKind::Fn(_, hir::TraitMethod::Required(pnames)) = item.kind {
346+
if let hir::TraitItemKind::Fn(_, hir::TraitFn::Required(pnames)) = item.kind {
347347
self.check_snake_case(cx, "trait method", &item.ident);
348348
for param_name in pnames {
349349
self.check_snake_case(cx, "variable", param_name);

src/librustc_metadata/rmeta/decoder.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ impl EntryKind {
505505
EntryKind::Struct(_, _) => DefKind::Struct,
506506
EntryKind::Union(_, _) => DefKind::Union,
507507
EntryKind::Fn(_) | EntryKind::ForeignFn(_) => DefKind::Fn,
508-
EntryKind::Method(_) => DefKind::AssocFn,
508+
EntryKind::AssocFn(_) => DefKind::AssocFn,
509509
EntryKind::Type => DefKind::TyAlias,
510510
EntryKind::TypeParam => DefKind::TyParam,
511511
EntryKind::ConstParam => DefKind::ConstParam,
@@ -1067,7 +1067,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
10671067

10681068
let (kind, container, has_self) = match self.kind(id) {
10691069
EntryKind::AssocConst(container, _, _) => (ty::AssocKind::Const, container, false),
1070-
EntryKind::Method(data) => {
1070+
EntryKind::AssocFn(data) => {
10711071
let data = data.decode(self);
10721072
(ty::AssocKind::Method, data.container, data.has_self)
10731073
}
@@ -1249,7 +1249,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12491249
fn get_fn_param_names(&self, id: DefIndex) -> Vec<ast::Name> {
12501250
let param_names = match self.kind(id) {
12511251
EntryKind::Fn(data) | EntryKind::ForeignFn(data) => data.decode(self).param_names,
1252-
EntryKind::Method(data) => data.decode(self).fn_data.param_names,
1252+
EntryKind::AssocFn(data) => data.decode(self).fn_data.param_names,
12531253
_ => Lazy::empty(),
12541254
};
12551255
param_names.decode(self).collect()
@@ -1286,7 +1286,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12861286
// don't serialize constness for tuple variant and tuple struct constructors.
12871287
fn is_const_fn_raw(&self, id: DefIndex) -> bool {
12881288
let constness = match self.kind(id) {
1289-
EntryKind::Method(data) => data.decode(self).fn_data.constness,
1289+
EntryKind::AssocFn(data) => data.decode(self).fn_data.constness,
12901290
EntryKind::Fn(data) => data.decode(self).constness,
12911291
// Some intrinsics can be const fn. While we could recompute this (at least until we
12921292
// stop having hardcoded whitelists and move to stability attributes), it seems cleaner
@@ -1301,7 +1301,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
13011301
fn asyncness(&self, id: DefIndex) -> hir::IsAsync {
13021302
match self.kind(id) {
13031303
EntryKind::Fn(data) => data.decode(self).asyncness,
1304-
EntryKind::Method(data) => data.decode(self).fn_data.asyncness,
1304+
EntryKind::AssocFn(data) => data.decode(self).fn_data.asyncness,
13051305
EntryKind::ForeignFn(data) => data.decode(self).asyncness,
13061306
_ => bug!("asyncness: expected function kind"),
13071307
}

0 commit comments

Comments
 (0)