diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-04-28 16:35:28 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-04-29 17:47:52 +1000 |
| commit | ae5f67f9e8a560c66d1c4afea1750d21f1d093e7 (patch) | |
| tree | 303ebd9275766a8b41d2c42282e8d62af8f7d77c | |
| parent | cde25f8dbe86c34dc4774107018b18974d9a14ee (diff) | |
| download | rust-ae5f67f9e8a560c66d1c4afea1750d21f1d093e7.tar.gz rust-ae5f67f9e8a560c66d1c4afea1750d21f1d093e7.zip | |
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.)
| -rw-r--r-- | compiler/rustc_ast/src/mut_visit.rs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 70e18a52c4c..c85b763a820 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -372,18 +372,14 @@ pub fn visit_mac_args<T: MutVisitor>(args: &mut MacArgs, vis: &mut T) { } MacArgs::Eq(eq_span, token) => { vis.visit_span(eq_span); - if T::VISIT_TOKENS { - visit_token(token, vis); - } else { - // The value in `#[key = VALUE]` must be visited as an expression for backward - // compatibility, so that macros can be expanded in that position. - match &mut token.kind { - token::Interpolated(nt) => match Lrc::make_mut(nt) { - token::NtExpr(expr) => vis.visit_expr(expr), - t => panic!("unexpected token in key-value attribute: {:?}", t), - }, + // The value in `#[key = VALUE]` must be visited as an expression for backward + // compatibility, so that macros can be expanded in that position. + match &mut token.kind { + token::Interpolated(nt) => match Lrc::make_mut(nt) { + token::NtExpr(expr) => vis.visit_expr(expr), t => panic!("unexpected token in key-value attribute: {:?}", t), - } + }, + t => panic!("unexpected token in key-value attribute: {:?}", t), } } } |
