feat: implement Go to Assignments for local variables#20481
feat: implement Go to Assignments for local variables#20481sgasho wants to merge 1 commit intorust-lang:masterfrom
Conversation
ce84d56 to
8748702
Compare
8748702 to
fbc6269
Compare
|
@rust-lang/rust-analyzer Sorry for the ping, but before starting review on this, I'd like to hear your opinions. I think this would be useful, but as it adds a new lsp extension and a right-click menu item, I'm a bit conservative on approving this |
|
I'm not opposed to having more kinds of goto refs, this can be quite useful, but since the possible numbers of extensions is large I think it is worth thinking about a more principled way, e.g. a filter dialog for goto refs. I don't think this needs to block this PR though (also it's probably impossible to make VSCode do anything). |
|
Some idea I had is to have some protocol extension to assign a "kind" (or maybe multiple kinds) to a reference, then the client can filter by it. |
|
Yea I think this is fine to add, if we add more over time we should rethink it. I wonder though, should this only track assignments or general writes, that is mutable borrows? |
|
☔ The latest upstream changes (possibly #21804) made this pull request unmergeable. Please resolve the merge conflicts. |
related: #18149
Summary
"Go to Assignments" for local variables as an initial implementation.
New detections like field accesses can be added to crates/ide/src/goto_assignments.rs but I wanted to reduce the diffs for this PR.
I'm gonna add other detections in another PR.
Evidence
for codes like this,

we can select "Go to Assignments",

and all assignments, including def, are shown.

The "a" in println() is not shown because it is not an assignment.