rust-lang / rust-lang/rust

Diagnostic deduplication breaks with incr comp

Open
#162,901 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics A-incr-comp C-bug D-diagnostic-infra T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

tests/ui/allocator/not-an-allocator.rs

#[global_allocator]
static A: usize = 0;
//~^ ERROR E0277
//~| ERROR E0277
//~| ERROR E0277
//~| ERROR E0277

fn main() {}

I expected to see this happen: Both without and with incr comp a single diagnostic.

Instead, this happened: Without incr comp a single diagnostic. With incr comp 4 duplicated diagnostics. With -Zdeduplicate-diagnostics=no in both cases 4 diagnostics are shown, but with incr comp it misses the message that the diagnostics were deduplicated.

Adding some debug prints shows that each diagnostic hashes to a different value with incr comp enabled, yet the debug print of the diagnostics are identical as is the DiagInner::keys() debug print.

Meta

rustc --version --verbose:

rustc 1.100.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.100.0-dev
LLVM version: 23.1.1

c999cef531ea9059e189e82fe0e82c5daf249bc9

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 tests/ui/allocator/not-an-allocator.rs and run the reproduction with and without incremental compilation, including -Zdeduplicate-diagnostics=no. Compare diagnostic counts, hashes, and the deduplication message; the fix is complete when incremental compilation matches the expected single-diagnostic behavior and the explicit no-deduplication mode remains consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.