Search code examples
visual-studio-coderustrust-analyzer

How to navigate to Rust sources in VSCode?


I have code something like this:

#[derive(Debug)]
struct Rectangle {
    width: u32,
    height: u32,
}

... and I'm want to dive into source of Debug.

In IntelliJ IDEA I'm put cursor on Debug and pressing cmd + b navigates me to Rust sources.

In VSCode I'm trying to get behavior like in IDEA:

  • put cursor on the same place (middle of on Debug word)
  • open right-click menu
  • press Go to definition (F12) or Go to Implementations(cmd + F12)

And VSCode shows me message No definition found for 'Debug'.

Is there a way to set up navigation by sources in VSCode like in IDEA?

I use this Rust extension in VSCode.


Solution

  • You can do it with the rust-analyzer extension, ctrl + click on Debug and it should work. If you are using the Rust extension I advice you against it as it was abandoned.