rust-lang / rust-lang/rust-analyzer
Expand macro output doesn't match actual output when forwarding `meta`
Open
Nobody has claimed this yet.
A-macro
C-bug
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
When working with meta in macros, expand command may show wrong output.
macro_rules! meta_bug {
(#[$m:meta]) => {
meta_bug! { @inner $m }
};
(@inner test) => { 0 };
(@inner $i:tt) => { 1 };
}
const RES: usize = meta_bug! { #[test] };
const _: () = assert!(RES == 1);
Unexpectedly, this example compiles, so RES is 1. But when expanding meta_bug! { #[test] } with rust-analyzer, it shows 0
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 with the provided macro_rules! reproducer and compare rust-analyzer's expand command output with the stable Rust compiler result. Trace how the forwarded meta fragment is matched during macro expansion; done means rust-analyzer reports 1 for meta_bug! { #[test] }, matching compilation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100