rust-lang / rust-lang/rust-analyzer
rust-analyzer finds wrong macro definition
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
macro_rules! m {
(1) => {};
}
m!(1);
mod inner {
m!(1); // error: RA finds m!(3)
macro_rules! m {
(2) => {};
}
m!(2); // error: RA finds m!(3)
macro_rules! m {
(3) => {};
}
m!(3);
}
m!(1);
Rust analyzer finds wrong macro definition when a macro shadows a previous one.
The above example was taken from Rust Reference.
rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P) 1.71.0
rustc version: (eg. output of rustc -V) 1.73.0
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)
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 reproducing the minimal macro-shadowing example from the issue in rust-analyzer and compare the resolved definitions with the Rust Reference's textual-scope rules. The fix is complete when m!(1), m!(2), and m!(3) each resolve to the corresponding macro definition, including calls before later shadowing definitions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100