diff options
| author | bors <bors@rust-lang.org> | 2024-01-22 11:08:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-01-22 11:08:57 +0000 |
| commit | 366d112fa69164d79239ceeaa49e06497df5497f (patch) | |
| tree | 4e0e6825c22283ddcea623bffbe5e8cf7388f44a /compiler/rustc_errors/src | |
| parent | 6fff796eac247c072ddb84f8202bedecc8e94f0d (diff) | |
| parent | 610f13d685bf04fa595ea6c1a88aaee2e00016d8 (diff) | |
| download | rust-366d112fa69164d79239ceeaa49e06497df5497f.tar.gz rust-366d112fa69164d79239ceeaa49e06497df5497f.zip | |
Auto merge of #120226 - matthiaskrgr:rollup-9xwx0si, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #118714 ( Explanation that fields are being used when deriving `(Partial)Ord` on enums) - #119710 (Improve `let_underscore_lock`) - #119726 (Tweak Library Integer Division Docs) - #119746 (rustdoc: hide modals when resizing the sidebar) - #119986 (Fix error counting) - #120194 (Shorten `#[must_use]` Diagnostic Message for `Option::is_none`) - #120200 (Correct the anchor of an URL in an error message) - #120203 (Replace `#!/bin/bash` with `#!/usr/bin/env bash` in rust-installer tests) - #120212 (Give nnethercote more reviews) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 141547b537d..9d80c456517 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -421,16 +421,16 @@ pub struct DiagCtxt { struct DiagCtxtInner { flags: DiagCtxtFlags, - /// The number of lint errors that have been emitted. + /// The number of lint errors that have been emitted, including duplicates. lint_err_count: usize, - /// The number of errors that have been emitted, including duplicates. - /// - /// This is not necessarily the count that's reported to the user once - /// compilation ends. + /// The number of non-lint errors that have been emitted, including duplicates. err_count: usize, + + /// The error count shown to the user at the end. deduplicated_err_count: usize, - /// The warning count, used for a recap upon finishing + /// The warning count shown to the user at the end. deduplicated_warn_count: usize, + /// Has this diagnostic context printed any diagnostics? (I.e. has /// `self.emitter.emit_diagnostic()` been called? has_printed: bool, @@ -927,11 +927,13 @@ impl DiagCtxt { self.struct_bug(msg).emit() } + /// This excludes lint errors and delayed bugs. #[inline] pub fn err_count(&self) -> usize { self.inner.borrow().err_count } + /// This excludes lint errors and delayed bugs. pub fn has_errors(&self) -> Option<ErrorGuaranteed> { self.inner.borrow().has_errors().then(|| { #[allow(deprecated)] @@ -939,30 +941,24 @@ impl DiagCtxt { }) } + /// This excludes delayed bugs. Unless absolutely necessary, prefer + /// `has_errors` to this method. pub fn has_errors_or_lint_errors(&self) -> Option<ErrorGuaranteed> { let inner = self.inner.borrow(); - let has_errors_or_lint_errors = inner.has_errors() || inner.lint_err_count > 0; - has_errors_or_lint_errors.then(|| { - #[allow(deprecated)] - ErrorGuaranteed::unchecked_claim_error_was_emitted() - }) - } - - pub fn has_errors_or_span_delayed_bugs(&self) -> Option<ErrorGuaranteed> { - let inner = self.inner.borrow(); - let has_errors_or_span_delayed_bugs = - inner.has_errors() || !inner.span_delayed_bugs.is_empty(); - has_errors_or_span_delayed_bugs.then(|| { + let result = inner.has_errors() || inner.lint_err_count > 0; + result.then(|| { #[allow(deprecated)] ErrorGuaranteed::unchecked_claim_error_was_emitted() }) } - pub fn is_compilation_going_to_fail(&self) -> Option<ErrorGuaranteed> { + /// Unless absolutely necessary, prefer `has_errors` or + /// `has_errors_or_lint_errors` to this method. + pub fn has_errors_or_lint_errors_or_delayed_bugs(&self) -> Option<ErrorGuaranteed> { let inner = self.inner.borrow(); - let will_fail = + let result = inner.has_errors() || inner.lint_err_count > 0 || !inner.span_delayed_bugs.is_empty(); - will_fail.then(|| { + result.then(|| { #[allow(deprecated)] ErrorGuaranteed::unchecked_claim_error_was_emitted() }) @@ -1162,7 +1158,7 @@ impl DiagCtxt { let mut inner = self.inner.borrow_mut(); if loud && lint_level.is_error() { - inner.err_count += 1; + inner.lint_err_count += 1; inner.panic_if_treat_err_as_bug(); } |
