Cleanup things in and around Diagnostic#119763
Merged
bors merged 6 commits intorust-lang:masterfrom Jan 11, 2024
Merged
Conversation
Collaborator
|
Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt The Miri subtree was changed cc @rust-lang/miri |
9886236 to
6034a69
Compare
Contributor
Author
|
I removed the last commit because I'm not sure if the |
Contributor
|
r? oli-obk |
oli-obk
reviewed
Jan 10, 2024
compiler/rustc_errors/src/lib.rs
Outdated
Comment on lines
1307
to
1306
| { | ||
| if diagnostic.has_future_breakage() { | ||
| (*TRACK_DIAGNOSTIC)(diagnostic, &mut |_| {}); | ||
| } | ||
| return None; | ||
| } | ||
|
|
||
| if matches!(diagnostic.level, Expect(_) | Allow) { | ||
| (*TRACK_DIAGNOSTIC)(diagnostic, &mut |_| {}); | ||
| return None; |
Contributor
There was a problem hiding this comment.
Please have a look at the PR that introduced them. I'm wary of removing them just because they have no effect on tests. This may be an incremental issue without tests. Alternatively verify from the source that this won't have an effect.
Contributor
Author
There was a problem hiding this comment.
Contributor
Author
There was a problem hiding this comment.
I have done this TRACK_DIAGNOSTIC change by itself in #120699, I'm now fairly confident it's correct. Details in that PR.
Because the values put into it are functions named `track_diagnostic` and `default_track_diagnostic`.
`is_force_warn` is only possible for diagnostics with `Level::Warning`, but it is currently stored in `Diagnostic::code`, which every diagnostic has. This commit: - removes the boolean `DiagnosticId::Lint::is_force_warn` field; - adds a `ForceWarning` variant to `Level`. Benefits: - The common `Level::Warning` case now has no arguments, replacing lots of `Warning(None)` occurrences. - `rustc_session::lint::Level` and `rustc_errors::Level` are more similar, both having `ForceWarning` and `Warning`.
It's missing but should obviously be included.
To put it next to a similar field.
There are four functions that adjust error and warning counts: - `stash_diagnostic` (increment) - `steal_diagnostic` (decrement) - `emit_stashed_diagnostics) (decrement) - `emit_diagnostic` (increment) The first three all behave similarly, and only update `warn_count` for forced warnings. But the last one updates `warn_count` for both forced and non-forced warnings. Seems like a bug. How should it be fixed? Well, `warn_count` is only used in one place: `DiagCtxtInner::drop`, where it's part of the condition relating to the printing of `good_path_delayed_bugs`. The intention of that condition seems to be "have any errors been printed?" so this commit replaces `warn_count` with `has_printed`, which is set when printing occurs. This is simpler than all the ahead-of-time incrementing and decrementing.
Of the error levels satisfying `is_error`, `Level::Error` is the only one that can be a lint, so there's no need to check for it. (And even if it wasn't, it would make more sense to include non-`Error`-but-`is_error` lints under `lint_err_count` than under `err_count`.)
6034a69 to
dd61eba
Compare
Contributor
|
@bors r+ |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jan 11, 2024
…iaskrgr Rollup of 11 pull requests Successful merges: - rust-lang#115046 (Use version-sorting for all sorting) - rust-lang#118915 (Add some comments, add `can_define_opaque_ty` check to `try_normalize_ty_recur`) - rust-lang#119006 (Fix is_global special address handling) - rust-lang#119637 (Pass LLVM error message back to pass wrapper.) - rust-lang#119715 (Exhaustiveness: abort on type error) - rust-lang#119763 (Cleanup things in and around `Diagnostic`) - rust-lang#119788 (change function name in comments) - rust-lang#119790 (Fix all_trait* methods to return all traits available in StableMIR) - rust-lang#119803 (Silence some follow-up errors [1/x]) - rust-lang#119804 (Stabilize mutex_unpoison feature) - rust-lang#119832 (Meta: Add project const traits to triagebot config) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jan 11, 2024
Rollup merge of rust-lang#119763 - nnethercote:cleanup-Diagnostic, r=oli-obk Cleanup things in and around `Diagnostic` These changes all arose when I was looking closely at how to simplify `DiagCtxtInner::emit_diagnostic`. r? `@compiler-errors`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These changes all arose when I was looking closely at how to simplify
DiagCtxtInner::emit_diagnostic.r? @compiler-errors