Skip to content

When deduplicating diagnostics, look at how it is rendered instead of its internal state#153794

Open
estebank wants to merge 1 commit intorust-lang:mainfrom
estebank:dedup-more
Open

When deduplicating diagnostics, look at how it is rendered instead of its internal state#153794
estebank wants to merge 1 commit intorust-lang:mainfrom
estebank:dedup-more

Conversation

@estebank
Copy link
Copy Markdown
Contributor

If two diagnostics are created differently (like two different structured diagnostics, or one using the Diag APIs), their internal state might be slightly different (because of the replacement variables). Which mean that the compiler can emit two errors that are visually indistinguishable. Change the hashing logic to consider the post expansion text for messages and labels so that they get properly deduplicated. Currently only two errors are directly fixed by this, but there are some duplicated errors with slightly different contents that can be modified to look the same so they are considered duplicates.

… its internal state

If two diagnostics are created differently (like two different structured diagnostics, or one using the Diag APIs), their internal state might be slightly different (because of the replacement variables). Which mean that the compiler can emit two errors that are visually indistinguishable. Change the hashing logic to consider the post expansion text for messages and labels so that they get properly deduplicated. Currently only two errors are directly fixed by this, but there are some duplicated errors with slightly different contents that can be modified to look the same so they are considered duplicates.
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 12, 2026

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 12, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 12, 2026

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 69 candidates
  • Random selection from 15 candidates


#[derive(Diagnostic)]
#[diag("constant evaluation is taking a long time")]
#[note("number of steps elapsed: {$force_duplicate}")]
Copy link
Copy Markdown
Member

@RalfJung RalfJung Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This number was not meant to be user-visible. Now that it is, we have to worry about what it represents. It counts how many ConstEvalCounter there have been... I don't actually know when and how those get emitted, and whether it is appropriate to call each of them one "step".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine showing it to users, but we need to filter it in UI tests, otherwise a lot of random changes will keep changing these tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An option would be to add an explicit disambiguation field to Diag independent of the message variables.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could totally imagine adding some kind of way to force including a field in the hash, regardless of whether it's shown in the output. That seems better than outputting the number of steps. Or even, having a way for diagnostics to "force no deduplication".

But alas, I'm also okay to go this path, but as Oli said, we should hide them in ui tests.

All in all, it's probably easier to edit the diagnostic hashing than wire through something special for ui tests.

@RalfJung
Copy link
Copy Markdown
Member

RalfJung commented Mar 12, 2026

It seems like you also changed at least one diagnostic to actually change its output to include previously deliberately hidden details. Are there other such cases? I am surprised this is not mentioned in the PR description.

@estebank
Copy link
Copy Markdown
Contributor Author

Are there other such cases?

This is indeed the only case I found in the entire test suite. I was going to try and find a separate alternative for that, specifically ensure that the first warning is actually emitted and the subsequent ones are silenced.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Mar 17, 2026

☔ The latest upstream changes (presumably #154008) made this pull request unmergeable. Please resolve the merge conflicts.

@jackh726
Copy link
Copy Markdown
Member

@jackh726 jackh726 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants