-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup things in and around Diagnostic
#119763
Conversation
Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt The Miri subtree was changed cc @rust-lang/miri |
9886236
to
6034a69
Compare
I removed the last commit because I'm not sure if the |
r? oli-obk |
compiler/rustc_errors/src/lib.rs
Outdated
if diagnostic.has_future_breakage() { | ||
(*TRACK_DIAGNOSTIC)(diagnostic, &mut |_| {}); | ||
} | ||
return None; | ||
} | ||
|
||
if matches!(diagnostic.level, Expect(_) | Allow) { | ||
(*TRACK_DIAGNOSTIC)(diagnostic, &mut |_| {}); | ||
return None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@bors r+ |
…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
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`
These changes all arose when I was looking closely at how to simplify
DiagCtxtInner::emit_diagnostic
.r? @compiler-errors