Language server
rust-analyzer serves.rs files. A workspace starts at the nearest Cargo.toml or rust-project.json.
While rust-analyzer is still loading a project, it has no answers for navigation yet. OpenIDEA waits for it instead of reporting “not found”: Declaration or Usages (⌘B / Ctrl+B) right after opening a project lands once the server is ready, for up to 30 seconds.
Diagnostics come from rust-analyzer’s own analysis and from cargo check (or Clippy) after each save.
Installing rust-analyzer
If rust-analyzer is missing, OpenIDEA shows a rust-analyzer is not installed notification with an Install button. You can also install it, or select your own binary, in Settings › Languages & Frameworks › Language Servers.- With rustup on
PATH, the IDE runsrustup component add rust-analyzer. - Without rustup, it downloads the rust-analyzer build from Open VSX into its own tools folder.
~/.cargo/bin/rust-analyzer is a rustup proxy that fails when the active toolchain lacks the component. In that case the IDE uses the newest installed toolchain that has rust-analyzer; if none has it, the server counts as missing and you get the install offer.
Setup
Settings › Languages & Frameworks › Rust has these options:
Reformat Code (
⌘⌥L / Ctrl+Alt+L) formats with rustfmt through rust-analyzer.
Crates and the Rust standard library appear under External Libraries in the Project view.
Run and test
OpenIDEA readsCargo.toml (and the members of a [workspace]) and detects:
In the editor, gutter icons run or debug:
fn maininsrc/main.rs,src/bin/*.rsandexamples/*.rs,- functions marked
#[test],#[tokio::test],#[async_std::test],#[actix_rt::test],#[rstest]or#[test_case], mod testsand modules marked#[cfg(test)], which run every test inside.
cargo test -- <path> --exact. Results appear in the test tree; Rerun Failed Tests runs only the failures. See Run configurations and Testing.
Build Project runs
cargo build --all-targets, Rebuild Project runs cargo clean first, and Build Artifacts runs cargo build --release. Compiler messages go to the Build tool window and the editor.
Run with Coverage uses cargo llvm-cov for cargo test, cargo run and cargo nextest configurations. If it is missing, the IDE offers cargo install cargo-llvm-cov (the llvm-tools-preview rustup component is needed too). See Coverage.
Debugging
Rust debugging uses CodeLLDB. If it is missing when you start a debug session, OpenIDEA offers to install it; it downloads the CodeLLDB release from GitHub into its tools folder. The cargo run and test configurations and the gutter icons can be debugged: CodeLLDB builds the target with cargo and starts the resulting binary. Attach to Process… (⌥⇧F5 / Ctrl+Alt+F5) lists native processes under Native (LLDB). See Debugging.
Limitations
- CodeLLDB publishes no Windows ARM64 build, so the IDE cannot install it there.
- rust-analyzer’s own extension commands, such as Expand Macro or View Syntax Tree, are not available as IDE actions.
- The profiler supports
cargo runonly on Linux (withperf). See Profiler.