rust-lang / rust-lang/cargo

Better associate rustc diagnostics to crate

Open
#8,977 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-console-output C-feature-request S-needs-design
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

I am seeing an unfortunate phenomenon where, since I have a lot of crates that are used in a lot of projects, statistically it happens very often that Cargo prints "Compiling [one of my crates]" immediately followed by a compiler diagnostic from some totally unrelated crate. The user sees something like the following and understands it to mean that the error occurred while compiling quote, which is true in a sense because the crates are compiling in parallel, but quite misleading.

$ cargo build
...
   Compiling quote v1.0.7
error[E0412]: cannot find type `DeviceState` in this scope
  --> /home/builder/.cargo/registry/src/github.com-1ecc6299db9ec823/device_query-0.2.7/src/lib.rs:39:22
   |
39 | impl DeviceQuery for DeviceState {
   |                      ^^^^^^^^^^^ not found in this scope

I have been seeing a rising number of misdirected bug reports on my crates due to this behavior.

I think it would help a lot if Cargo could guarantee that compiler diagnostics were always printed below "Compiling [that exact crate]" (or equivalently labeled in some way), even if it means double-printing "Compiling [that exact crate]" or some terminal UI hack.

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 with the cargo build output path that prints Compiling lines and forwards rustc diagnostics while crates build in parallel. Reproduce the example using the issue's command and verify that each diagnostic is clearly associated with the crate that produced it, including when compilation is concurrent.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.