Skip to content

Commit 3aeb9f0

Browse files
committed
rename TraitItemKind::Method -> Fn
1 parent 98c7ed6 commit 3aeb9f0

File tree

31 files changed

+67
-70
lines changed

31 files changed

+67
-70
lines changed

src/librustc/hir/map/blocks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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::Method(_, hir::TraitMethod::Provided(_)) => true,
63+
hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => true,
6464
_ => false,
6565
}
6666
}
@@ -239,7 +239,7 @@ impl<'a> FnLikeNode<'a> {
239239
_ => bug!("item FnLikeNode that is not fn-like"),
240240
},
241241
Node::TraitItem(ti) => match ti.kind {
242-
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
242+
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::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"),

src/librustc/hir/map/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'hir> Entry<'hir> {
5151
},
5252

5353
Node::TraitItem(ref item) => match item.kind {
54-
TraitItemKind::Method(ref sig, _) => Some(&sig.decl),
54+
TraitItemKind::Fn(ref sig, _) => Some(&sig.decl),
5555
_ => None,
5656
},
5757

@@ -77,7 +77,7 @@ impl<'hir> Entry<'hir> {
7777
},
7878

7979
Node::TraitItem(item) => match &item.kind {
80-
TraitItemKind::Method(sig, _) => Some(sig),
80+
TraitItemKind::Fn(sig, _) => Some(sig),
8181
_ => None,
8282
},
8383

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

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

@@ -326,7 +326,7 @@ impl<'hir> Map<'hir> {
326326
},
327327
Node::TraitItem(item) => match item.kind {
328328
TraitItemKind::Const(..) => DefKind::AssocConst,
329-
TraitItemKind::Method(..) => DefKind::AssocFn,
329+
TraitItemKind::Fn(..) => DefKind::AssocFn,
330330
TraitItemKind::Type(..) => DefKind::AssocTy,
331331
},
332332
Node::ImplItem(item) => match item.kind {
@@ -473,7 +473,7 @@ impl<'hir> Map<'hir> {
473473
| Node::AnonConst(_) => BodyOwnerKind::Const,
474474
Node::Ctor(..)
475475
| Node::Item(&Item { kind: ItemKind::Fn(..), .. })
476-
| Node::TraitItem(&TraitItem { kind: TraitItemKind::Method(..), .. })
476+
| Node::TraitItem(&TraitItem { kind: TraitItemKind::Fn(..), .. })
477477
| Node::ImplItem(&ImplItem { kind: ImplItemKind::Method(..), .. }) => BodyOwnerKind::Fn,
478478
Node::Item(&Item { kind: ItemKind::Static(_, m, _), .. }) => BodyOwnerKind::Static(m),
479479
Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => BodyOwnerKind::Closure,
@@ -801,7 +801,7 @@ impl<'hir> Map<'hir> {
801801
_ => false,
802802
},
803803
Node::TraitItem(ti) => match ti.kind {
804-
TraitItemKind::Method(..) => true,
804+
TraitItemKind::Fn(..) => true,
805805
_ => false,
806806
},
807807
Node::ImplItem(ii) => match ii.kind {
@@ -1312,7 +1312,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
13121312
Some(Node::TraitItem(ti)) => {
13131313
let kind = match ti.kind {
13141314
TraitItemKind::Const(..) => "assoc constant",
1315-
TraitItemKind::Method(..) => "trait method",
1315+
TraitItemKind::Fn(..) => "trait method",
13161316
TraitItemKind::Type(..) => "assoc type",
13171317
};
13181318

src/librustc_ast_lowering/item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,13 +767,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
767767
let names = self.lower_fn_params_to_names(&sig.decl);
768768
let (generics, sig) =
769769
self.lower_method_sig(generics, sig, trait_item_def_id, false, None);
770-
(generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Required(names)))
770+
(generics, hir::TraitItemKind::Fn(sig, hir::TraitMethod::Required(names)))
771771
}
772772
AssocItemKind::Fn(_, ref sig, ref generics, Some(ref body)) => {
773773
let body_id = self.lower_fn_body_block(i.span, &sig.decl, Some(body));
774774
let (generics, sig) =
775775
self.lower_method_sig(generics, sig, trait_item_def_id, false, None);
776-
(generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Provided(body_id)))
776+
(generics, hir::TraitItemKind::Fn(sig, hir::TraitMethod::Provided(body_id)))
777777
}
778778
AssocItemKind::TyAlias(_, ref generics, ref bounds, ref default) => {
779779
let ty = default.as_ref().map(|x| self.lower_ty(x, ImplTraitContext::disallowed()));

src/librustc_hir/hir.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,8 +1863,8 @@ pub enum TraitMethod<'hir> {
18631863
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>),
1866-
/// A method with an optional body.
1867-
Method(FnSig<'hir>, TraitMethod<'hir>),
1866+
/// An associated function with an optional body.
1867+
Fn(FnSig<'hir>, TraitMethod<'hir>),
18681868
/// An associated type with (possibly empty) bounds and optional concrete
18691869
/// type.
18701870
Type(GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
@@ -2699,7 +2699,7 @@ impl Node<'_> {
26992699

27002700
pub fn fn_decl(&self) -> Option<&FnDecl<'_>> {
27012701
match self {
2702-
Node::TraitItem(TraitItem { kind: TraitItemKind::Method(fn_sig, _), .. })
2702+
Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
27032703
| Node::ImplItem(ImplItem { kind: ImplItemKind::Method(fn_sig, _), .. })
27042704
| Node::Item(Item { kind: ItemKind::Fn(fn_sig, _, _), .. }) => Some(fn_sig.decl),
27052705
Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_decl, _, _), .. }) => {

src/librustc_hir/intravisit.rs

Lines changed: 2 additions & 2 deletions
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::Method(ref sig, TraitMethod::Required(param_names)) => {
914+
TraitItemKind::Fn(ref sig, TraitMethod::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::Method(ref sig, TraitMethod::Provided(body_id)) => {
921+
TraitItemKind::Fn(ref sig, TraitMethod::Provided(body_id)) => {
922922
visitor.visit_fn(
923923
FnKind::Method(trait_item.ident, sig, None, &trait_item.attrs),
924924
&sig.decl,

src/librustc_hir/print.rs

Lines changed: 2 additions & 2 deletions
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::Method(ref sig, hir::TraitMethod::Required(ref arg_names)) => {
889+
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::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::Method(ref sig, hir::TraitMethod::Provided(body)) => {
895+
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => {
896896
let vis =
897897
Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Inherited };
898898
self.head("");

src/librustc_hir/target.rs

Lines changed: 2 additions & 2 deletions
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::Method(_, hir::TraitMethod::Required(_)) => {
108+
TraitItemKind::Fn(_, hir::TraitMethod::Required(_)) => {
109109
Target::Method(MethodKind::Trait { body: false })
110110
}
111-
TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => {
111+
TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => {
112112
Target::Method(MethodKind::Trait { body: true })
113113
}
114114
TraitItemKind::Type(..) => Target::AssocTy,

src/librustc_incremental/persist/dirty_clean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl DirtyCleanVisitor<'tcx> {
328328
}
329329
}
330330
HirNode::TraitItem(item) => match item.kind {
331-
TraitItemKind::Method(..) => ("Node::TraitItem", LABELS_FN_IN_TRAIT),
331+
TraitItemKind::Fn(..) => ("Node::TraitItem", LABELS_FN_IN_TRAIT),
332332
TraitItemKind::Const(..) => ("NodeTraitConst", LABELS_CONST_IN_TRAIT),
333333
TraitItemKind::Type(..) => ("NodeTraitType", LABELS_CONST_IN_TRAIT),
334334
},

src/librustc_infer/infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ fn item_scope_tag(item: &hir::Item<'_>) -> &'static str {
269269

270270
fn trait_item_scope_tag(item: &hir::TraitItem<'_>) -> &'static str {
271271
match item.kind {
272-
hir::TraitItemKind::Method(..) => "method body",
272+
hir::TraitItemKind::Fn(..) => "method body",
273273
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => "associated item",
274274
}
275275
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
3333
let fndecl = match self.tcx().hir().get(hir_id) {
3434
Node::Item(&hir::Item { kind: hir::ItemKind::Fn(ref m, ..), .. })
3535
| Node::TraitItem(&hir::TraitItem {
36-
kind: hir::TraitItemKind::Method(ref m, ..),
36+
kind: hir::TraitItemKind::Fn(ref m, ..),
3737
..
3838
})
3939
| Node::ImplItem(&hir::ImplItem {

0 commit comments

Comments
 (0)