Skip to content

Commit 6f85f20

Browse files
committed
Add Ident to FnKind::Fn, just like with the immutable visitor
1 parent e426f26 commit 6f85f20

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ pub trait NoopVisitItemKind {
3939
fn noop_visit(
4040
&mut self,
4141
ctxt: Option<AssocCtxt>,
42+
ident: Ident,
4243
span: Span,
4344
id: NodeId,
4445
visitor: &mut impl MutVisitor,
@@ -895,7 +896,7 @@ fn noop_visit_coroutine_kind<T: MutVisitor>(coroutine_kind: &mut CoroutineKind,
895896

896897
fn noop_visit_fn<T: MutVisitor>(kind: FnKind<'_>, vis: &mut T) {
897898
match kind {
898-
FnKind::Fn(_ctxt, FnSig { header, decl, span }, generics, body) => {
899+
FnKind::Fn(_ctxt, _ident, FnSig { header, decl, span }, generics, body) => {
899900
// Identifier and visibility are visited as a part of the item.
900901
vis.visit_fn_header(header);
901902
vis.visit_generics(generics);
@@ -1096,17 +1097,19 @@ pub fn noop_visit_block<T: MutVisitor>(block: &mut P<Block>, vis: &mut T) {
10961097

10971098
pub fn noop_visit_item_kind(
10981099
kind: &mut impl NoopVisitItemKind,
1100+
ident: Ident,
10991101
span: Span,
11001102
id: NodeId,
11011103
vis: &mut impl MutVisitor,
11021104
) {
1103-
kind.noop_visit(None, span, id, vis)
1105+
kind.noop_visit(None, ident, span, id, vis)
11041106
}
11051107

11061108
impl NoopVisitItemKind for ItemKind {
11071109
fn noop_visit(
11081110
&mut self,
11091111
ctxt: Option<AssocCtxt>,
1112+
ident: Ident,
11101113
span: Span,
11111114
id: NodeId,
11121115
vis: &mut impl MutVisitor,
@@ -1124,7 +1127,7 @@ impl NoopVisitItemKind for ItemKind {
11241127
}
11251128
ItemKind::Fn(box Fn { defaultness, generics, sig, body }) => {
11261129
visit_defaultness(defaultness, vis);
1127-
vis.visit_fn(FnKind::Fn(FnCtxt::Free, sig, generics, body), span, id);
1130+
vis.visit_fn(FnKind::Fn(FnCtxt::Free, ident, sig, generics, body), span, id);
11281131
}
11291132
ItemKind::Mod(safety, mod_kind) => {
11301133
visit_safety(safety, vis);
@@ -1226,6 +1229,7 @@ impl NoopVisitItemKind for AssocItemKind {
12261229
fn noop_visit(
12271230
&mut self,
12281231
ctxt: Option<AssocCtxt>,
1232+
ident: Ident,
12291233
span: Span,
12301234
id: NodeId,
12311235
visitor: &mut impl MutVisitor,
@@ -1237,7 +1241,11 @@ impl NoopVisitItemKind for AssocItemKind {
12371241
}
12381242
AssocItemKind::Fn(box Fn { defaultness, generics, sig, body }) => {
12391243
visit_defaultness(defaultness, visitor);
1240-
visitor.visit_fn(FnKind::Fn(FnCtxt::Assoc(ctxt), sig, generics, body), span, id);
1244+
visitor.visit_fn(
1245+
FnKind::Fn(FnCtxt::Assoc(ctxt), ident, sig, generics, body),
1246+
span,
1247+
id,
1248+
);
12411249
}
12421250
AssocItemKind::Type(box TyAlias {
12431251
defaultness,
@@ -1328,7 +1336,7 @@ pub fn noop_flat_map_item<K: NoopVisitItemKind>(
13281336
visit_attrs(attrs, visitor);
13291337
visitor.visit_vis(vis);
13301338
visitor.visit_ident(ident);
1331-
kind.noop_visit(ctxt, *span, *id, visitor);
1339+
kind.noop_visit(ctxt, *ident, *span, *id, visitor);
13321340
visit_lazy_tts(tokens, visitor);
13331341
visitor.visit_span(span);
13341342
smallvec![item]
@@ -1338,6 +1346,7 @@ impl NoopVisitItemKind for ForeignItemKind {
13381346
fn noop_visit(
13391347
&mut self,
13401348
ctxt: Option<AssocCtxt>,
1349+
ident: Ident,
13411350
span: Span,
13421351
id: NodeId,
13431352
visitor: &mut impl MutVisitor,
@@ -1350,7 +1359,7 @@ impl NoopVisitItemKind for ForeignItemKind {
13501359
}
13511360
ForeignItemKind::Fn(box Fn { defaultness, generics, sig, body }) => {
13521361
visit_defaultness(defaultness, visitor);
1353-
visitor.visit_fn(FnKind::Fn(FnCtxt::Foreign, sig, generics, body), span, id);
1362+
visitor.visit_fn(FnKind::Fn(FnCtxt::Foreign, ident, sig, generics, body), span, id);
13541363
}
13551364
ForeignItemKind::TyAlias(box TyAlias {
13561365
defaultness,
@@ -1824,7 +1833,7 @@ impl<N: DummyAstNode, T: DummyAstNode> DummyAstNode for crate::ast_traits::AstNo
18241833
#[derive(Debug)]
18251834
pub enum FnKind<'a> {
18261835
/// E.g., `fn foo()`, `fn foo(&self)`, or `extern "Abi" fn foo()`.
1827-
Fn(FnCtxt, &'a mut FnSig, &'a mut Generics, &'a mut Option<P<Block>>),
1836+
Fn(FnCtxt, Ident, &'a mut FnSig, &'a mut Generics, &'a mut Option<P<Block>>),
18281837

18291838
/// E.g., `|x, y| body`.
18301839
Closure(&'a mut ClosureBinder, &'a mut P<FnDecl>, &'a mut P<Expr>),

compiler/rustc_builtin_macros/src/test_harness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> {
144144
item.kind
145145
{
146146
let prev_tests = mem::take(&mut self.tests);
147-
noop_visit_item_kind(&mut item.kind, item.span, item.id, self);
147+
noop_visit_item_kind(&mut item.kind, item.ident, item.span, item.id, self);
148148
self.add_test_cases(item.id, span, prev_tests);
149149
} else {
150150
// But in those cases, we emit a lint to warn the user of these missing tests.

0 commit comments

Comments
 (0)