Skip to content

Commit ae5f67f

Browse files
committed
Remove the T::VISIT_TOKENS test in visit_mac_args.
The two paths are equivalent -- they both end up calling `visit_expr()`. I have kept the more restrictive path, the one that requires that `token` be an expression nonterminal. (The next commit will simplify this function further.)
1 parent cde25f8 commit ae5f67f

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

compiler/rustc_ast/src/mut_visit.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -372,18 +372,14 @@ pub fn visit_mac_args<T: MutVisitor>(args: &mut MacArgs, vis: &mut T) {
372372
}
373373
MacArgs::Eq(eq_span, token) => {
374374
vis.visit_span(eq_span);
375-
if T::VISIT_TOKENS {
376-
visit_token(token, vis);
377-
} else {
378-
// The value in `#[key = VALUE]` must be visited as an expression for backward
379-
// compatibility, so that macros can be expanded in that position.
380-
match &mut token.kind {
381-
token::Interpolated(nt) => match Lrc::make_mut(nt) {
382-
token::NtExpr(expr) => vis.visit_expr(expr),
383-
t => panic!("unexpected token in key-value attribute: {:?}", t),
384-
},
375+
// The value in `#[key = VALUE]` must be visited as an expression for backward
376+
// compatibility, so that macros can be expanded in that position.
377+
match &mut token.kind {
378+
token::Interpolated(nt) => match Lrc::make_mut(nt) {
379+
token::NtExpr(expr) => vis.visit_expr(expr),
385380
t => panic!("unexpected token in key-value attribute: {:?}", t),
386-
}
381+
},
382+
t => panic!("unexpected token in key-value attribute: {:?}", t),
387383
}
388384
}
389385
}

0 commit comments

Comments
 (0)