diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-12-20 10:18:08 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-12-23 13:23:28 +1100 |
| commit | 1502596ca264b8f059e94de29715b17841d52e7d (patch) | |
| tree | 101737bcac7ccccaa715c35b284617695c0a114e | |
| parent | 6f147afea9d35f466bcdcefbc9cf0d85bed3a2e6 (diff) | |
| download | rust-1502596ca264b8f059e94de29715b17841d52e7d.tar.gz rust-1502596ca264b8f059e94de29715b17841d52e7d.zip | |
Introduce `DiagCtxt::treat_next_err_as_bug`.
To fix a FIXME.
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index f09d9c95381..119881d85b4 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -992,13 +992,7 @@ impl DiagCtxt { msg: impl Into<DiagnosticMessage>, ) -> ErrorGuaranteed { let mut inner = self.inner.borrow_mut(); - - // This is technically `self.treat_err_as_bug()` but `span_delayed_bug` is called before - // incrementing `err_count` by one, so we need to +1 the comparing. - // FIXME: Would be nice to increment err_count in a more coherent way. - if inner.flags.treat_err_as_bug.is_some_and(|c| { - inner.err_count + inner.lint_err_count + inner.delayed_bug_count() + 1 >= c.get() - }) { + if inner.treat_next_err_as_bug() { // FIXME: don't abort here if report_delayed_bugs is off inner.span_bug(sp, msg); } @@ -1519,6 +1513,13 @@ impl DiagCtxtInner { }) } + // Use this one before incrementing `err_count`. + fn treat_next_err_as_bug(&self) -> bool { + self.flags.treat_err_as_bug.is_some_and(|c| { + self.err_count + self.lint_err_count + self.delayed_bug_count() + 1 >= c.get() + }) + } + fn delayed_bug_count(&self) -> usize { self.span_delayed_bugs.len() + self.good_path_delayed_bugs.len() } |
