-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.F-macro_metavar_expr`#![feature(macro_metavar_expr)]``#![feature(macro_metavar_expr)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
(playground, updated 2024-01-25 to account for a change to the syntax of macro metavariable expressions)
#![feature(macro_metavar_expr)]
#![warn(meta_variable_misuse)]
macro_rules! foo {
($($id:ident),* $(,)?) => {
${count($id)}
};
}
fn main() {
assert_eq!(foo!(a, b, c), 3);
}
Current output
warning: variable 'id' is still repeating at this depth
--> src/main.rs:6:10
|
5 | ($($id:ident),* $(,)?) => {
| - expected repetition
6 | ${count($id)}
| ^^^^^^^^^^^^
|
note: the lint level is defined here
--> src/main.rs:2:9
|
2 | #![warn(meta_variable_misuse)]
| ^^^^^^^^^^^^^^^^^^^^
Desired output
No diagnostics should be emitted.
Rationale and extra context
This code builds and runs just fine; ${count($foo)}
doesn't have to be in a repetition of $foo
.
Anything else?
@rustbot modify labels +A-macros +D-papercut +F-macro-metavar-expr
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.F-macro_metavar_expr`#![feature(macro_metavar_expr)]``#![feature(macro_metavar_expr)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.