Skip to content

Commit e52f902

Browse files
committed
AssocImplKind::{Method -> Fn}.
1 parent abf2e7a commit e52f902

File tree

16 files changed

+31
-35
lines changed

16 files changed

+31
-35
lines changed

Diff for: src/librustc/hir/lowering.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ impl<'a> LoweringContext<'a> {
481481
self.lctx.allocate_hir_id_counter(item.id);
482482

483483
match item.kind {
484-
AssocItemKind::Method(_, None) => {
484+
AssocItemKind::Fn(_, None) => {
485485
// Ignore patterns in trait methods without bodies
486486
self.with_hir_id_owner(None, |this| {
487487
visit::walk_trait_item(this, item)

Diff for: src/librustc/hir/lowering/item.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ impl LoweringContext<'_> {
826826
.map(|x| self.lower_const_body(i.span, Some(x))),
827827
),
828828
),
829-
AssocItemKind::Method(ref sig, None) => {
829+
AssocItemKind::Fn(ref sig, None) => {
830830
let names = self.lower_fn_params_to_names(&sig.decl);
831831
let (generics, sig) = self.lower_method_sig(
832832
&i.generics,
@@ -837,7 +837,7 @@ impl LoweringContext<'_> {
837837
);
838838
(generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Required(names)))
839839
}
840-
AssocItemKind::Method(ref sig, Some(ref body)) => {
840+
AssocItemKind::Fn(ref sig, Some(ref body)) => {
841841
let body_id = self.lower_fn_body_block(i.span, &sig.decl, Some(body));
842842
let (generics, sig) = self.lower_method_sig(
843843
&i.generics,
@@ -880,7 +880,7 @@ impl LoweringContext<'_> {
880880
AssocItemKind::TyAlias(_, ref default) => {
881881
(hir::AssocItemKind::Type, default.is_some())
882882
}
883-
AssocItemKind::Method(ref sig, ref default) => (
883+
AssocItemKind::Fn(ref sig, ref default) => (
884884
hir::AssocItemKind::Method {
885885
has_self: sig.decl.has_self(),
886886
},
@@ -913,7 +913,7 @@ impl LoweringContext<'_> {
913913
self.lower_const_body(i.span, expr.as_deref()),
914914
),
915915
),
916-
AssocItemKind::Method(ref sig, ref body) => {
916+
AssocItemKind::Fn(ref sig, ref body) => {
917917
self.current_item = Some(i.span);
918918
let body_id = self.lower_maybe_async_body(
919919
i.span,
@@ -984,7 +984,7 @@ impl LoweringContext<'_> {
984984
None => hir::AssocItemKind::Type,
985985
Some(_) => hir::AssocItemKind::OpaqueTy,
986986
},
987-
AssocItemKind::Method(sig, _) => hir::AssocItemKind::Method {
987+
AssocItemKind::Fn(sig, _) => hir::AssocItemKind::Method {
988988
has_self: sig.decl.has_self(),
989989
},
990990
AssocItemKind::Macro(..) => unimplemented!(),

Diff for: src/librustc_interface/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> {
779779
fn flat_map_trait_item(&mut self, i: ast::AssocItem) -> SmallVec<[ast::AssocItem; 1]> {
780780
let is_const = match i.kind {
781781
ast::AssocItemKind::Const(..) => true,
782-
ast::AssocItemKind::Method(ref sig, _) => Self::is_sig_const(sig),
782+
ast::AssocItemKind::Fn(ref sig, _) => Self::is_sig_const(sig),
783783
_ => false,
784784
};
785785
self.run(is_const, |s| noop_flat_map_assoc_item(i, s))

Diff for: src/librustc_lint/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ impl EarlyLintPass for UnsafeCode {
269269
}
270270

271271
fn check_trait_item(&mut self, cx: &EarlyContext<'_>, item: &ast::AssocItem) {
272-
if let ast::AssocItemKind::Method(ref sig, None) = item.kind {
272+
if let ast::AssocItemKind::Fn(ref sig, None) = item.kind {
273273
if sig.header.unsafety == ast::Unsafety::Unsafe {
274274
self.report_unsafe(cx, item.span, "declaration of an `unsafe` method")
275275
}
@@ -617,7 +617,7 @@ declare_lint_pass!(
617617
impl EarlyLintPass for AnonymousParameters {
618618
fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::AssocItem) {
619619
match it.kind {
620-
ast::AssocItemKind::Method(ref sig, _) => {
620+
ast::AssocItemKind::Fn(ref sig, _) => {
621621
for arg in sig.decl.inputs.iter() {
622622
match arg.pat.kind {
623623
ast::PatKind::Ident(_, ident, None) => {

Diff for: src/librustc_parse/parser/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,7 @@ impl<'a> Parser<'a> {
17901790
})?;
17911791
let sig = FnSig { header, decl };
17921792
let body = self.parse_assoc_fn_body(at_end, attrs)?;
1793-
Ok((ident, AssocItemKind::Method(sig, body), generics))
1793+
Ok((ident, AssocItemKind::Fn(sig, body), generics))
17941794
}
17951795

17961796
/// Parse the "body" of a method in an associated item definition.

Diff for: src/librustc_passes/ast_validation.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
544544
}
545545
for impl_item in impl_items {
546546
self.invalid_visibility(&impl_item.vis, None);
547-
if let AssocItemKind::Method(ref sig, _) = impl_item.kind {
547+
if let AssocItemKind::Fn(ref sig, _) = impl_item.kind {
548548
self.check_trait_fn_not_const(sig.header.constness);
549549
self.check_trait_fn_not_async(impl_item.span, sig.header.asyncness.node);
550550
}
@@ -795,7 +795,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
795795
AssocItemKind::Const(_, body) => {
796796
self.check_impl_item_provided(ii.span, body, "constant", " = <expr>;");
797797
}
798-
AssocItemKind::Method(sig, body) => {
798+
AssocItemKind::Fn(sig, body) => {
799799
self.check_impl_item_provided(ii.span, body, "function", " { <body> }");
800800
self.check_fn_decl(&sig.decl);
801801
}
@@ -812,7 +812,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
812812
self.invalid_visibility(&ti.vis, None);
813813
self.check_defaultness(ti.span, ti.defaultness);
814814

815-
if let AssocItemKind::Method(sig, block) = &ti.kind {
815+
if let AssocItemKind::Fn(sig, block) = &ti.kind {
816816
self.check_fn_decl(&sig.decl);
817817
self.check_trait_fn_not_async(ti.span, sig.header.asyncness.node);
818818
self.check_trait_fn_not_const(sig.header.constness);
@@ -838,7 +838,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
838838
}
839839

840840
fn visit_assoc_item(&mut self, item: &'a AssocItem) {
841-
if let AssocItemKind::Method(sig, _) = &item.kind {
841+
if let AssocItemKind::Fn(sig, _) = &item.kind {
842842
self.check_c_varadic_type(&sig.decl);
843843
}
844844
visit::walk_assoc_item(self, item);

Diff for: src/librustc_resolve/build_reduced_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
11761176
let item_def_id = self.r.definitions.local_def_id(item.id);
11771177
let (res, ns) = match item.kind {
11781178
AssocItemKind::Const(..) => (Res::Def(DefKind::AssocConst, item_def_id), ValueNS),
1179-
AssocItemKind::Method(ref sig, _) => {
1179+
AssocItemKind::Fn(ref sig, _) => {
11801180
if sig.decl.has_self() {
11811181
self.r.has_self.insert(item_def_id);
11821182
}

Diff for: src/librustc_resolve/def_collector.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,8 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
214214

215215
fn visit_trait_item(&mut self, ti: &'a AssocItem) {
216216
let def_data = match ti.kind {
217-
AssocItemKind::Method(..) | AssocItemKind::Const(..) =>
218-
DefPathData::ValueNs(ti.ident.name),
219-
AssocItemKind::TyAlias(..) => {
220-
DefPathData::TypeNs(ti.ident.name)
221-
},
217+
AssocItemKind::Fn(..) | AssocItemKind::Const(..) => DefPathData::ValueNs(ti.ident.name),
218+
AssocItemKind::TyAlias(..) => DefPathData::TypeNs(ti.ident.name),
222219
AssocItemKind::Macro(..) => return self.visit_macro_invoc(ti.id),
223220
};
224221

@@ -228,7 +225,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
228225

229226
fn visit_impl_item(&mut self, ii: &'a AssocItem) {
230227
let def_data = match ii.kind {
231-
AssocItemKind::Method(FnSig {
228+
AssocItemKind::Fn(FnSig {
232229
ref header,
233230
ref decl,
234231
}, ref body) if header.asyncness.node.is_async() => {
@@ -242,7 +239,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
242239
body.as_deref(),
243240
)
244241
}
245-
AssocItemKind::Method(..) |
242+
AssocItemKind::Fn(..) |
246243
AssocItemKind::Const(..) => DefPathData::ValueNs(ii.ident.name),
247244
AssocItemKind::TyAlias(..) => DefPathData::TypeNs(ii.ident.name),
248245
AssocItemKind::Macro(..) => return self.visit_macro_invoc(ii.id),

Diff for: src/librustc_resolve/late.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
818818
});
819819
}
820820
}
821-
AssocItemKind::Method(_, _) => {
821+
AssocItemKind::Fn(_, _) => {
822822
visit::walk_assoc_item(this, trait_item)
823823
}
824824
AssocItemKind::TyAlias(..) => {
@@ -1109,7 +1109,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
11091109
visit::walk_assoc_item(this, impl_item)
11101110
});
11111111
}
1112-
AssocItemKind::Method(..) => {
1112+
AssocItemKind::Fn(..) => {
11131113
// If this is a trait impl, ensure the method
11141114
// exists in trait
11151115
this.check_trait_item(impl_item.ident,

Diff for: src/librustc_save_analysis/dump_visitor.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
10441044
&trait_item.attrs,
10451045
);
10461046
}
1047-
ast::AssocItemKind::Method(ref sig, ref body) => {
1047+
ast::AssocItemKind::Fn(ref sig, ref body) => {
10481048
self.process_method(
10491049
sig,
10501050
body.as_ref().map(|x| &**x),
@@ -1115,7 +1115,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
11151115
&impl_item.attrs,
11161116
);
11171117
}
1118-
ast::AssocItemKind::Method(ref sig, ref body) => {
1118+
ast::AssocItemKind::Fn(ref sig, ref body) => {
11191119
self.process_method(
11201120
sig,
11211121
body.as_deref(),

Diff for: src/libsyntax/ast.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1634,8 +1634,7 @@ pub enum AssocItemKind {
16341634
Const(P<Ty>, Option<P<Expr>>),
16351635

16361636
/// An associated function.
1637-
/// FIXME(Centril): Rename to `Fn`.
1638-
Method(FnSig, Option<P<Block>>),
1637+
Fn(FnSig, Option<P<Block>>),
16391638

16401639
/// An associated type.
16411640
TyAlias(GenericBounds, Option<P<Ty>>),

Diff for: src/libsyntax/feature_gate/check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
573573

574574
fn visit_trait_item(&mut self, ti: &'a ast::AssocItem) {
575575
match ti.kind {
576-
ast::AssocItemKind::Method(ref sig, ref block) => {
576+
ast::AssocItemKind::Fn(ref sig, ref block) => {
577577
if block.is_none() {
578578
self.check_extern(sig.header.ext);
579579
}
@@ -600,7 +600,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
600600
}
601601

602602
match ii.kind {
603-
ast::AssocItemKind::Method(ref sig, _) => {
603+
ast::AssocItemKind::Fn(ref sig, _) => {
604604
if sig.decl.c_variadic() {
605605
gate_feature_post!(
606606
&self, c_variadic, ii.span,

Diff for: src/libsyntax/mut_visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ pub fn noop_flat_map_assoc_item<T: MutVisitor>(mut item: AssocItem, visitor: &mu
955955
visitor.visit_ty(ty);
956956
visit_opt(expr, |expr| visitor.visit_expr(expr));
957957
}
958-
AssocItemKind::Method(sig, body) => {
958+
AssocItemKind::Fn(sig, body) => {
959959
visit_fn_sig(sig, visitor);
960960
visit_opt(body, |body| visitor.visit_block(body));
961961
}

Diff for: src/libsyntax/print/pprust.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ impl<'a> State<'a> {
15281528
ast::AssocItemKind::Const(ty, expr) => {
15291529
self.print_associated_const(item.ident, ty, expr.as_deref(), &item.vis);
15301530
}
1531-
ast::AssocItemKind::Method(sig, body) => {
1531+
ast::AssocItemKind::Fn(sig, body) => {
15321532
if body.is_some() {
15331533
self.head("");
15341534
}

Diff for: src/libsyntax/visit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -600,11 +600,11 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a AssocItem)
600600
visitor.visit_ty(ty);
601601
walk_list!(visitor, visit_expr, expr);
602602
}
603-
AssocItemKind::Method(ref sig, None) => {
603+
AssocItemKind::Fn(ref sig, None) => {
604604
visitor.visit_fn_header(&sig.header);
605605
walk_fn_decl(visitor, &sig.decl);
606606
}
607-
AssocItemKind::Method(ref sig, Some(ref body)) => {
607+
AssocItemKind::Fn(ref sig, Some(ref body)) => {
608608
visitor.visit_fn(FnKind::Method(item.ident, sig, &item.vis, body),
609609
&sig.decl, item.span, item.id);
610610
}

Diff for: src/libsyntax_ext/deriving/generic/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ impl<'a> MethodDef<'a> {
958958
vis: respan(trait_lo_sp, ast::VisibilityKind::Inherited),
959959
defaultness: ast::Defaultness::Final,
960960
ident: method_ident,
961-
kind: ast::AssocItemKind::Method(sig, Some(body_block)),
961+
kind: ast::AssocItemKind::Fn(sig, Some(body_block)),
962962
tokens: None,
963963
}
964964
}

0 commit comments

Comments
 (0)