rust-lang / rust-lang/rust-analyzer

Display Cargo errors (and other startup errors) as structured diagnostics

Open
#19,969 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-cargo A-diagnostics A-vfs C-feature
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Whenever there is some error from Cargo which prevents compilation from starting, I have to hover over the rust-analyzer status bar widget, wait for it to appear, and look at the raw text output without moving the mouse. In complex cases, I need to run cargo check in a terminal to get legible information.

It would be useful if, instead, rust-analyzer displayed these diagnostics through the usual LSP channels (i.e. so that they show in the Problems pane in VS Code, as editor underlines, etc.), associated with the problematic Cargo.toml manifest file if possible, or the workspace root manifest if not. This would greatly streamline the workflow for fixing manifest problems.

There should also be a diagnostic associated with the workspace root if Cargo commands fail to execute for any reason, even if there is not a normal Cargo error (e.g. if rustup reports that the requested toolchain is not available).

Related issue: #11124 is only asking for surfacing Cargo warnings.

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

No files or tests are named. Start by tracing rust-analyzer's Cargo startup handling, including the status-bar raw output and LSP diagnostic entry points; reproduce a Cargo manifest failure and an unavailable-toolchain failure. Done means both cases appear as diagnostics in the Problems pane and editor, associated with the relevant Cargo.toml or workspace root.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.