rust-lang / rust-lang/rust-analyzer
Range hover inside macro is wrong
Open
Nobody has claimed this yet.
A-hover
A-macro
C-bug
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rust-analyzer version: rust-analyzer version: 0.3.1348-standalone (643bc02de 2023-01-01)
rustc version: rustc 1.64.0 (a55dd71d5 2022-09-19)
macro_rules! test_macro {
($e: expr) => {
{
let _ = $e;
()
}
};
}
fn test() {
let a = test_macro!(5 + 5);
// ^^^^^ hover show ()
let b = 5 + 5;
// ^^^^^ hover show i32
}
Actual:
When I hover over 5 + 5, RA shows error type (), it seems that RA marks the whole test_macro!(5 + 5) as a hover range.


Excepted:
Show i32
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
Reproduce the hover behavior with the Rust macro example in the issue, comparing the macro argument with the direct expression. Trace rust-analyzer's hover range handling across macro expansion, and consider the issue complete when hovering 5 + 5 inside test_macro! reports i32 rather than ().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100