Macros do not accept empty vis
at the end of the token tree #131950
Open
Description
I tried this code:
macro_rules! m {
( ($v:vis) ) => {};
}
fn main() {
m!( () );
}
I expected to see this happen: the code compile successfully. The reference says vis
is "a possibly empty Visibility qualifier", so it should match empty.
Instead, this happened: the code is rejected with:
error: no rules expected the token `)`
--> src/main.rs:6:10
|
1 | macro_rules! m {
| -------------- when calling this macro
...
6 | m!( () );
| ^ no rules expected this token in macro call
|
note: while trying to match meta-variable `$v:vis`
--> src/main.rs:2:8
|
2 | ( ($v:vis) ) => {};
| ^^^^^^
@rustbot label +A-macros