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

src/librustc/hir/lowering.rs

Lines changed: 1 addition & 1 deletion
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)

src/librustc/hir/lowering/item.rs

Lines changed: 5 additions & 5 deletions
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!(),

src/librustc_interface/util.rs

Lines changed: 1 addition & 1 deletion
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))

src/librustc_lint/builtin.rs

Lines changed: 2 additions & 2 deletions
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) => {

src/librustc_parse/parser/item.rs

Lines changed: 1 addition & 1 deletion
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.

src/librustc_passes/ast_validation.rs

Lines changed: 4 additions & 4 deletions
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);

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 1 addition & 1 deletion
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
}

src/librustc_resolve/def_collector.rs

Lines changed: 4 additions & 7 deletions
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),

src/librustc_resolve/late.rs

Lines changed: 2 additions & 2 deletions
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,

src/librustc_save_analysis/dump_visitor.rs

Lines changed: 2 additions & 2 deletions
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(),

0 commit comments

Comments
 (0)