rust-analyzer provides Rust IDE features through editors that support the Language Server Protocol (LSP). Use it for code completion, import insertion, definition navigation, inline compiler errors, type and parameter inlay hints, and refactoring. section 3.2
To use it in VS Code:
- Install the rust-src component with `rustup component add rust-src`, then install the rust-analyzer extension. section 3.6
- Open a Rust project; the extension recognizes its Cargo.toml and loads the project. Run `code .` from the project directory to open it there. section 3.6
$ rustup component add rust-src
Command for installing the rust-src component before VS Code setup. section 3.6
For a context-aware rename in VS Code, select a symbol and press F2 or choose Rename Symbol. For broader changes, structural search-and-replace matches parsed expressions, types, paths, or items rather than raw text. It applies substitutions across the workspace by default and only accepts results that are syntactically valid. section 6.7.2
Replace a method call structurally
Use `$m.lock() => Mutex::lock(&$m)` to change matching Mutex method calls to the equivalent associated-function form. With `use std::sync::Mutex` in scope, the replacement can name `Mutex::lock` without writing its full path. section 6.7.2
Prefer symbol renaming or structural replacement over plain find-and-replace when a change depends on Rust syntax or name context. Other LSP-capable editors can also integrate rust-analyzer; IntelliJ Rust does not require a separate rust-analyzer extension. section 6.7.2 section 3.2
