rust-lang / rust-lang/rust-analyzer
Improve derive macro helper input tokens span
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I noticed that once the generated result contains a span from the helper, all call-sites in the derived macro will point to every argument tt of the helper
This makes it difficult to goto-define and view hover in helpers
#[derive(serde::Serialize)]
struct Foo {
#[serde(skip_serializing_if = "Option::is_none")]
x: Option<i32>,
}
Cursor on is_none hover to output a large amount, such as extern crate serde
And the goto-definition also has multiple results pointing to the inside of the serde
Currently, call-site be obtained on is_none.
Expected to be obtained on the helper name (serde) instead of the helper argument (skip_serializing_if and "Option::is_none")
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 derive-macro example with serde and inspect rust-analyzer's handling of helper input tokens and call-site spans; the issue names no source file or test. Done means hover and goto-definition on is_none resolve using the helper name span, such as serde, rather than the helper arguments.
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
- 40/100