Macros do not accept empty `vis` at the end of the token tree
Open
Nobody has claimed this yet.
A-macros
C-bug
T-compiler
T-lang
WG-macros
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by compiling the Rust reproducer in src/main.rs or the linked Playground and confirm that an empty vis at the end of the token tree is rejected. Trace the macro-by-example matching behavior described in the report; done means the example compiles successfully while preserving the documented behavior of vis metavariables.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100