Skip to content

Commit 17b2af8

Browse files
committed
Add Ident to FnKind::Fn, just like with the immutable visitor
1 parent dc59c71 commit 17b2af8

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

compiler/rustc_ast/src/mut_visit.rs

+16-7
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,
@@ -908,7 +909,7 @@ fn noop_visit_coroutine_kind<T: MutVisitor>(coroutine_kind: &mut CoroutineKind,
908909

909910
fn noop_visit_fn<T: MutVisitor>(kind: FnKind<'_>, vis: &mut T) {
910911
match kind {
911-
FnKind::Fn(_ctxt, FnSig { header, decl, span }, generics, body) => {
912+
FnKind::Fn(_ctxt, _ident, FnSig { header, decl, span }, generics, body) => {
912913
// Identifier and visibility are visited as a part of the item.
913914
vis.visit_fn_header(header);
914915
vis.visit_generics(generics);
@@ -1109,17 +1110,19 @@ pub fn noop_visit_block<T: MutVisitor>(block: &mut P<Block>, vis: &mut T) {
11091110

11101111
pub fn noop_visit_item_kind(
11111112
kind: &mut impl NoopVisitItemKind,
1113+
ident: Ident,
11121114
span: Span,
11131115
id: NodeId,
11141116
vis: &mut impl MutVisitor,
11151117
) {
1116-
kind.noop_visit(None, span, id, vis)
1118+
kind.noop_visit(None, ident, span, id, vis)
11171119
}
11181120

11191121
impl NoopVisitItemKind for ItemKind {
11201122
fn noop_visit(
11211123
&mut self,
11221124
ctxt: Option<AssocCtxt>,
1125+
ident: Ident,
11231126
span: Span,
11241127
id: NodeId,
11251128
vis: &mut impl MutVisitor,
@@ -1137,7 +1140,7 @@ impl NoopVisitItemKind for ItemKind {
11371140
}
11381141
ItemKind::Fn(box Fn { defaultness, generics, sig, body }) => {
11391142
visit_defaultness(defaultness, vis);
1140-
vis.visit_fn(FnKind::Fn(FnCtxt::Free, sig, generics, body), span, id);
1143+
vis.visit_fn(FnKind::Fn(FnCtxt::Free, ident, sig, generics, body), span, id);
11411144
}
11421145
ItemKind::Mod(safety, mod_kind) => {
11431146
visit_safety(safety, vis);
@@ -1239,6 +1242,7 @@ impl NoopVisitItemKind for AssocItemKind {
12391242
fn noop_visit(
12401243
&mut self,
12411244
ctxt: Option<AssocCtxt>,
1245+
ident: Ident,
12421246
span: Span,
12431247
id: NodeId,
12441248
visitor: &mut impl MutVisitor,
@@ -1250,7 +1254,11 @@ impl NoopVisitItemKind for AssocItemKind {
12501254
}
12511255
AssocItemKind::Fn(box Fn { defaultness, generics, sig, body }) => {
12521256
visit_defaultness(defaultness, visitor);
1253-
visitor.visit_fn(FnKind::Fn(FnCtxt::Assoc(ctxt), sig, generics, body), span, id);
1257+
visitor.visit_fn(
1258+
FnKind::Fn(FnCtxt::Assoc(ctxt), ident, sig, generics, body),
1259+
span,
1260+
id,
1261+
);
12541262
}
12551263
AssocItemKind::Type(box TyAlias {
12561264
defaultness,
@@ -1341,7 +1349,7 @@ pub fn noop_flat_map_item<K: NoopVisitItemKind>(
13411349
visit_attrs(attrs, visitor);
13421350
visitor.visit_vis(vis);
13431351
visitor.visit_ident(ident);
1344-
kind.noop_visit(ctxt, *span, *id, visitor);
1352+
kind.noop_visit(ctxt, *ident, *span, *id, visitor);
13451353
visit_lazy_tts(tokens, visitor);
13461354
visitor.visit_span(span);
13471355
smallvec![item]
@@ -1351,6 +1359,7 @@ impl NoopVisitItemKind for ForeignItemKind {
13511359
fn noop_visit(
13521360
&mut self,
13531361
ctxt: Option<AssocCtxt>,
1362+
ident: Ident,
13541363
span: Span,
13551364
id: NodeId,
13561365
visitor: &mut impl MutVisitor,
@@ -1363,7 +1372,7 @@ impl NoopVisitItemKind for ForeignItemKind {
13631372
}
13641373
ForeignItemKind::Fn(box Fn { defaultness, generics, sig, body }) => {
13651374
visit_defaultness(defaultness, visitor);
1366-
visitor.visit_fn(FnKind::Fn(FnCtxt::Foreign, sig, generics, body), span, id);
1375+
visitor.visit_fn(FnKind::Fn(FnCtxt::Foreign, ident, sig, generics, body), span, id);
13671376
}
13681377
ForeignItemKind::TyAlias(box TyAlias {
13691378
defaultness,
@@ -1837,7 +1846,7 @@ impl<N: DummyAstNode, T: DummyAstNode> DummyAstNode for crate::ast_traits::AstNo
18371846
#[derive(Debug)]
18381847
pub enum FnKind<'a> {
18391848
/// E.g., `fn foo()`, `fn foo(&self)`, or `extern "Abi" fn foo()`.
1840-
Fn(FnCtxt, &'a mut FnSig, &'a mut Generics, &'a mut Option<P<Block>>),
1849+
Fn(FnCtxt, Ident, &'a mut FnSig, &'a mut Generics, &'a mut Option<P<Block>>),
18411850

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

compiler/rustc_builtin_macros/src/test_harness.rs

+1-1
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)