rust-lang / rust-lang/rust-analyzer
Find all usages skips usages in derives
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Consider the following minimal example:
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
struct X {
x: i32,
}
fn main() {
println!("Hello, world!");
}
Use f12 on Deserialize to go to definition, then shift-alt-f12 to find all references. Note that the only reference in main.rs is in the use, not on the derive. This was initially found at https://github.com/rust-lang/rust-analyzer/pull/14723#issuecomment-1674760317. I believe the bug holds more generally with usages in proc-macros. This causes issues when running remove unused imports in a file which has serde derives in it.
rust-analyzer version: rust-analyzer version: 0.3.1631-standalone (83b3ba1b8 2023-08-19)
rustc version: rustc 1.73.0-nightly (0d95f9132 2023-07-26)
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 report in main.rs using the minimal serde example, then compare F12 definition results with Shift-Alt-F12 references for Deserialize. Done means usages inside the derive are included alongside the use statement, and removing unused imports no longer treats the serde import as unused.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100