rust-lang / rust-lang/rust-analyzer

[Feature Request] Go to Definition from the comments

Open
#10,700 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

In clangd we have some simple heuristics to provide Go to Definition for symbols mentioned in the comments. If there are structs/functions/<...> with he same name around the comment, we allow jumping to that symbol right from the comment. I find it really useful and it helps navigate the code faster, so it would be really nice to have something like this in rust-analyzer.

Ideally, this could be even more advanced than what we have in clangd since Rust does have a rich comment format that can actually reference symbols and provide better documentation. I've tried pressing gd on some of the type names in Rust Standard Library and in toy examples like the one I have below for clangd but nothing happened.

https://user-images.githubusercontent.com/3352968/140510608-bec099f1-7657-46eb-8109-c75e8a77454e.mov

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported behavior in rust-analyzer with the Rust Standard Library and the linked toy example or video. Define which symbols in comments should support Go to Definition, then verify that the selected references navigate correctly and that Rust's richer comment references are handled as intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.