Skip to content

Commit 73714bb

Browse files
committed
Introduce DiagCtxt::treat_next_err_as_bug.
To fix a FIXME.
1 parent 6c6d134 commit 73714bb

File tree

1 file changed

+8
-7
lines changed
  • compiler/rustc_errors/src

1 file changed

+8
-7
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -979,13 +979,7 @@ impl DiagCtxt {
979979
msg: impl Into<DiagnosticMessage>,
980980
) -> ErrorGuaranteed {
981981
let mut inner = self.inner.borrow_mut();
982-
983-
// This is technically `self.treat_err_as_bug()` but `span_delayed_bug` is called before
984-
// incrementing `err_count` by one, so we need to +1 the comparing.
985-
// FIXME: Would be nice to increment err_count in a more coherent way.
986-
if inner.flags.treat_err_as_bug.is_some_and(|c| {
987-
inner.err_count + inner.lint_err_count + inner.delayed_bug_count() + 1 >= c.get()
988-
}) {
982+
if inner.treat_next_err_as_bug() {
989983
// FIXME: don't abort here if report_delayed_bugs is off
990984
inner.span_bug(sp, msg);
991985
}
@@ -1506,6 +1500,13 @@ impl DiagCtxtInner {
15061500
})
15071501
}
15081502

1503+
// Use this one before incrementing `err_count`.
1504+
fn treat_next_err_as_bug(&self) -> bool {
1505+
self.flags.treat_err_as_bug.is_some_and(|c| {
1506+
self.err_count + self.lint_err_count + self.delayed_bug_count() + 1 >= c.get()
1507+
})
1508+
}
1509+
15091510
fn delayed_bug_count(&self) -> usize {
15101511
self.span_delayed_bugs.len() + self.good_path_delayed_bugs.len()
15111512
}

0 commit comments

Comments
 (0)