Skip to content

Simplify diagnostic levels - #162514

Merged
rust-bors[bot] merged 6 commits into
rust-lang:mainfrom
nnethercote:simplify-diag-Levels
Sep 11, 2026
Merged

Simplify diagnostic levels#162514
rust-bors[bot] merged 6 commits into
rust-lang:mainfrom
nnethercote:simplify-diag-Levels

Conversation

@nnethercote

@nnethercote nnethercote commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

View all comments

This PR separates diagnostic levels from subdiagnostic levels and does a few preliminary cleanups. Details in individual commits.

r? @oli-obk

@rustbot

rustbot commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

rustc_errors::annotate_snippet_emitter_writer was changed

cc @Muscraft

rustc_errors::emitter was changed

cc @Muscraft

rustc_errors::formatting was changed

cc @TaKO8Ki, @JonathanBrouwer

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic 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 Sep 9, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors try @rust-timer queue
Not expecting anything, but just in case

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 9, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 9, 2026
@nnethercote

Copy link
Copy Markdown
Contributor Author

LLM disclosure: this PR is partially based on suggestions from an LLM. I made all the code and text changes myself.

@rust-bors

rust-bors Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: c68fbe3 (c68fbe3704dbd3fea3c81cb930471661303f3cf9)
Base parent: 1edd55d (1edd55dcfcd573872c727fa3e086369a71661ee0)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (c68fbe3): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.1%, 0.2%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 2
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -0.0%, secondary -1.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.5% [0.4%, 0.6%] 6
Regressions ❌
(secondary)
1.1% [1.1%, 1.1%] 2
Improvements ✅
(primary)
-0.8% [-1.3%, -0.5%] 4
Improvements ✅
(secondary)
-2.9% [-3.3%, -2.3%] 3
All ❌✅ (primary) -0.0% [-1.3%, 0.6%] 10

Cycles

Results (primary -0.5%, secondary -1.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.6% [0.4%, 0.9%] 4
Regressions ❌
(secondary)
4.0% [3.6%, 4.3%] 4
Improvements ✅
(primary)
-0.9% [-2.7%, -0.4%] 12
Improvements ✅
(secondary)
-4.3% [-6.9%, -2.4%] 6
All ❌✅ (primary) -0.5% [-2.7%, 0.9%] 16

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 481.679s -> 482.596s (0.19%)
Artifact size: 403.98 MiB -> 403.37 MiB (-0.15%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 9, 2026
@nnethercote

Copy link
Copy Markdown
Contributor Author

Just include-blob noise.

@petrochenkov

Copy link
Copy Markdown
Contributor

This partially intersects with #162057.

@nnethercote

Copy link
Copy Markdown
Contributor Author

This partially intersects with #162057.

True: the "Remove emit_almost_fatal" commit from that PR is basically identical to the Remove "almost fatal" errors commit in this PR. So I have removed that commit.

Comment thread compiler/rustc_errors/src/lib.rs Outdated
let not_yet_emitted = |sub: &mut Subdiag| {
debug!(?sub);
if sub.level != OnceNote && sub.level != OnceHelp {
if sub.level != Sublevel::OnceNote && sub.level != Sublevel::OnceHelp {

@oli-obk oli-obk Sep 9, 2026

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.

preexisting, but with the fewer variants now it is probably nicer to just make it an exhaustive match

View changes since the review

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.

done

@rustbot rustbot 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 Sep 10, 2026
@rustbot

rustbot commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot

This comment has been minimized.

@nnethercote

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 10, 2026
@oli-obk

oli-obk commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 01e1453 has been approved by oli-obk

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

Reason for tree closure: git config problem again

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 10, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 10, 2026
…r=oli-obk

Simplify diagnostic levels

This PR separates diagnostic levels from subdiagnostic levels and does a few preliminary cleanups. Details in individual commits.

r? @oli-obk
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 10, 2026
…r=oli-obk

Simplify diagnostic levels

This PR separates diagnostic levels from subdiagnostic levels and does a few preliminary cleanups. Details in individual commits.

r? @oli-obk
@rust-bors rust-bors Bot 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 10, 2026
@rust-bors

This comment has been minimized.

These are dead since the old emitter was removed in Jan 2026
(3ccabc6).

Also removed: `BRIGHT_BLUE`, `Level::color`, and a couple of `level`
fn parameters.
It has a single use, where it is passed in to `format_diag_messages`
which then discards it. So that use can be replaced with
`Style::NoStyle`.
`format_diag_messages` always constructs a `String`, so it can just
return that. This simplifies various call sites.
When there's a single message, `format_diag_message` suffices.
Use the `FatalError` re-export from `rustc_errors` instead of
`rustc_span`, because that's what's normally done.
Currently `Level` is used for both diagnostics and subdiagnostics. But
both diagnostics and subdiagnostics only use some of the levels. This
commit introduces `Sublevel` to tighten up the representation and
prevent impossible combinations.
@rustbot

rustbot commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@nnethercote

Copy link
Copy Markdown
Contributor Author

I rebased.

@bors r=oli-obk

@rust-bors

rust-bors Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 6331ab6 has been approved by oli-obk

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 10, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Sep 10, 2026
…r=oli-obk

Simplify diagnostic levels

This PR separates diagnostic levels from subdiagnostic levels and does a few preliminary cleanups. Details in individual commits.

r? @oli-obk
rust-bors Bot pushed a commit that referenced this pull request Sep 11, 2026
Rollup of 5 pull requests

Successful merges:

 - #162270 (Update `windows-bindgen` to 0.100.0)
 - #162492 (Revert "Rollup merge of #157518 - CAD97:xdg_basedir, r=aapoalas")
 - #162607 (Basic cleanup in `rustc_transmute`)
 - #162514 (Simplify diagnostic levels)
 - #162613 (iter::repeat_with, iter::successors, iter::from_fn added as diagnostic items)
rust-bors Bot pushed a commit that referenced this pull request Sep 11, 2026
Rollup of 10 pull requests

Successful merges:

 - #162270 (Update `windows-bindgen` to 0.100.0)
 - #162492 (Revert "Rollup merge of #157518 - CAD97:xdg_basedir, r=aapoalas")
 - #162607 (Basic cleanup in `rustc_transmute`)
 - #162619 (Add test for the missing Clone requirement for Cow slices)
 - #162172 (mention the opaque when its hidden type cannot be inferred)
 - #162514 (Simplify diagnostic levels)
 - #162546 (Use lld by default on `loongarch64-unknown-linux-gnu` nightly)
 - #162564 (yeet StabilityLevel)
 - #162613 (iter::repeat_with, iter::successors, iter::from_fn added as diagnostic items)
 - #162616 (regression test for async main diagnostic)
@rust-bors
rust-bors Bot merged commit d971af8 into rust-lang:main Sep 11, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 11, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 11, 2026
Rollup merge of #162514 - nnethercote:simplify-diag-Levels, r=oli-obk

Simplify diagnostic levels

This PR separates diagnostic levels from subdiagnostic levels and does a few preliminary cleanups. Details in individual commits.

r? @oli-obk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants