Skip to content

Commit 5dad689

Browse files
committed
Add Ident to FnKind::Fn, just like with the immutable visitor
1 parent 9f6994b commit 5dad689

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,
@@ -897,7 +898,7 @@ fn noop_visit_coroutine_kind<T: MutVisitor>(coroutine_kind: &mut CoroutineKind,
897898

898899
fn noop_visit_fn<T: MutVisitor>(kind: FnKind<'_>, vis: &mut T) {
899900
match kind {
900-
FnKind::Fn(_ctxt, FnSig { header, decl, span }, generics, body) => {
901+
FnKind::Fn(_ctxt, _ident, FnSig { header, decl, span }, generics, body) => {
901902
// Identifier and visibility are visited as a part of the item.
902903
vis.visit_fn_header(header);
903904
vis.visit_generics(generics);
@@ -1098,17 +1099,19 @@ pub fn noop_visit_block<T: MutVisitor>(block: &mut P<Block>, vis: &mut T) {
10981099

10991100
pub fn noop_visit_item_kind(
11001101
kind: &mut impl NoopVisitItemKind,
1102+
ident: Ident,
11011103
span: Span,
11021104
id: NodeId,
11031105
vis: &mut impl MutVisitor,
11041106
) {
1105-
kind.noop_visit(None, span, id, vis)
1107+
kind.noop_visit(None, ident, span, id, vis)
11061108
}
11071109

11081110
impl NoopVisitItemKind for ItemKind {
11091111
fn noop_visit(
11101112
&mut self,
11111113
ctxt: Option<AssocCtxt>,
1114+
ident: Ident,
11121115
span: Span,
11131116
id: NodeId,
11141117
vis: &mut impl MutVisitor,
@@ -1126,7 +1129,7 @@ impl NoopVisitItemKind for ItemKind {
11261129
}
11271130
ItemKind::Fn(box Fn { defaultness, generics, sig, body }) => {
11281131
visit_defaultness(defaultness, vis);
1129-
vis.visit_fn(FnKind::Fn(FnCtxt::Free, sig, generics, body), span, id);
1132+
vis.visit_fn(FnKind::Fn(FnCtxt::Free, ident, sig, generics, body), span, id);
11301133
}
11311134
ItemKind::Mod(safety, mod_kind) => {
11321135
visit_safety(safety, vis);
@@ -1228,6 +1231,7 @@ impl NoopVisitItemKind for AssocItemKind {
12281231
fn noop_visit(
12291232
&mut self,
12301233
ctxt: Option<AssocCtxt>,
1234+
ident: Ident,
12311235
span: Span,
12321236
id: NodeId,
12331237
visitor: &mut impl MutVisitor,
@@ -1239,7 +1243,11 @@ impl NoopVisitItemKind for AssocItemKind {
12391243
}
12401244
AssocItemKind::Fn(box Fn { defaultness, generics, sig, body }) => {
12411245
visit_defaultness(defaultness, visitor);
1242-
visitor.visit_fn(FnKind::Fn(FnCtxt::Assoc(ctxt), sig, generics, body), span, id);
1246+
visitor.visit_fn(
1247+
FnKind::Fn(FnCtxt::Assoc(ctxt), ident, sig, generics, body),
1248+
span,
1249+
id,
1250+
);
12431251
}
12441252
AssocItemKind::Type(box TyAlias {
12451253
defaultness,
@@ -1330,7 +1338,7 @@ pub fn noop_flat_map_item<K: NoopVisitItemKind>(
13301338
visit_attrs(attrs, visitor);
13311339
visitor.visit_vis(vis);
13321340
visitor.visit_ident(ident);
1333-
kind.noop_visit(ctxt, *span, *id, visitor);
1341+
kind.noop_visit(ctxt, *ident, *span, *id, visitor);
13341342
visit_lazy_tts(tokens, visitor);
13351343
visitor.visit_span(span);
13361344
smallvec![item]
@@ -1340,6 +1348,7 @@ impl NoopVisitItemKind for ForeignItemKind {
13401348
fn noop_visit(
13411349
&mut self,
13421350
ctxt: Option<AssocCtxt>,
1351+
ident: Ident,
13431352
span: Span,
13441353
id: NodeId,
13451354
visitor: &mut impl MutVisitor,
@@ -1352,7 +1361,7 @@ impl NoopVisitItemKind for ForeignItemKind {
13521361
}
13531362
ForeignItemKind::Fn(box Fn { defaultness, generics, sig, body }) => {
13541363
visit_defaultness(defaultness, visitor);
1355-
visitor.visit_fn(FnKind::Fn(FnCtxt::Foreign, sig, generics, body), span, id);
1364+
visitor.visit_fn(FnKind::Fn(FnCtxt::Foreign, ident, sig, generics, body), span, id);
13561365
}
13571366
ForeignItemKind::TyAlias(box TyAlias {
13581367
defaultness,
@@ -1826,7 +1835,7 @@ impl<N: DummyAstNode, T: DummyAstNode> DummyAstNode for crate::ast_traits::AstNo
18261835
#[derive(Debug)]
18271836
pub enum FnKind<'a> {
18281837
/// E.g., `fn foo()`, `fn foo(&self)`, or `extern "Abi" fn foo()`.
1829-
Fn(FnCtxt, &'a mut FnSig, &'a mut Generics, &'a mut Option<P<Block>>),
1838+
Fn(FnCtxt, Ident, &'a mut FnSig, &'a mut Generics, &'a mut Option<P<Block>>),
18301839

18311840
/// E.g., `|x, y| body`.
18321841
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)