Skip to content

Commit

Permalink
Simplify lint error counting.
Browse files Browse the repository at this point in the history
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`.)
  • Loading branch information
nnethercote committed Jan 9, 2024
1 parent b0183e5 commit 6034a69
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ impl DiagCtxt {
let key = (span.with_parent(None), key);

if diag.is_error() {
if diag.level == Error && diag.is_lint {
if diag.is_lint {
inner.lint_err_count += 1;
} else {
inner.err_count += 1;
Expand All @@ -691,7 +691,7 @@ impl DiagCtxt {
let key = (span.with_parent(None), key);
let diag = inner.stashed_diagnostics.remove(&key)?;
if diag.is_error() {
if diag.level == Error && diag.is_lint {
if diag.is_lint {
inner.lint_err_count -= 1;
} else {
inner.err_count -= 1;
Expand Down Expand Up @@ -1231,7 +1231,7 @@ impl DiagCtxtInner {
for diag in diags {
// Decrement the count tracking the stash; emitting will increment it.
if diag.is_error() {
if diag.level == Error && diag.is_lint {
if diag.is_lint {
self.lint_err_count -= 1;
} else {
self.err_count -= 1;
Expand Down Expand Up @@ -1344,7 +1344,7 @@ impl DiagCtxtInner {
self.has_printed = true;
}
if diagnostic.is_error() {
if diagnostic.level == Error && diagnostic.is_lint {
if diagnostic.is_lint {
self.bump_lint_err_count();
} else {
self.bump_err_count();
Expand Down

0 comments on commit 6034a69

Please sign in to comment.