Skip to content

feat: implement Go to Assignments for local variables#20481

Open
sgasho wants to merge 1 commit intorust-lang:masterfrom
sgasho:feat/18149_goto_assignments_local_vars
Open

feat: implement Go to Assignments for local variables#20481
sgasho wants to merge 1 commit intorust-lang:masterfrom
sgasho:feat/18149_goto_assignments_local_vars

Conversation

@sgasho
Copy link
Contributor

@sgasho sgasho commented Aug 18, 2025

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,
スクリーンショット 2025-08-19 0 44 32

we can select "Go to Assignments",
スクリーンショット 2025-08-19 0 44 24

and all assignments, including def, are shown.
The "a" in println() is not shown because it is not an assignment.
スクリーンショット 2025-08-19 0 44 40

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 18, 2025
@sgasho sgasho force-pushed the feat/18149_goto_assignments_local_vars branch 2 times, most recently from ce84d56 to 8748702 Compare August 18, 2025 16:16
@sgasho sgasho force-pushed the feat/18149_goto_assignments_local_vars branch from 8748702 to fbc6269 Compare August 18, 2025 16:41
@ShoyuVanilla
Copy link
Member

@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

@ChayimFriedman2
Copy link
Contributor

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).

@ChayimFriedman2
Copy link
Contributor

ChayimFriedman2 commented Sep 29, 2025

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.

@Veykril
Copy link
Member

Veykril commented Oct 26, 2025

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?

@rustbot
Copy link
Collaborator

rustbot commented Mar 12, 2026

☔ The latest upstream changes (possibly #21804) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants