Skip to content

Commit 2b5325d

Browse files
authored
Rollup merge of #71489 - spastorino:fix-treat-err-as-bug-handling, r=eddyb
Fix off by one in treat err as bug `-Ztreat-err-as-bug` doesn't work properly with delay_span_bug. r? @eddyb
2 parents 5aebbe9 + 3fe2804 commit 2b5325d

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/librustc_errors/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,10 @@ impl HandlerInner {
869869
}
870870

871871
fn delay_span_bug(&mut self, sp: impl Into<MultiSpan>, msg: &str) {
872-
if self.treat_err_as_bug() {
872+
// This is technically `self.treat_err_as_bug()` but `delay_span_bug` is called before
873+
// incrementing `err_count` by one, so we need to +1 the comparing.
874+
// FIXME: Would be nice to increment err_count in a more coherent way.
875+
if self.flags.treat_err_as_bug.map(|c| self.err_count() + 1 >= c).unwrap_or(false) {
873876
// FIXME: don't abort here if report_delayed_bugs is off
874877
self.span_bug(sp, msg);
875878
}

src/test/run-make-fulldeps/treat-err-as-bug/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
all:
44
$(RUSTC) err.rs -Z treat-err-as-bug 2>&1 \
55
| $(CGREP) "panicked at 'aborting due to \`-Z treat-err-as-bug=1\`'"
6+
$(RUSTC) delay_span_bug.rs -Z treat-err-as-bug 2>&1 \
7+
| $(CGREP) "panicked at 'aborting due to \`-Z treat-err-as-bug=1\`'"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#![feature(rustc_attrs)]
2+
3+
#[rustc_error(delay_span_bug_from_inside_query)]
4+
fn main() {}

0 commit comments

Comments
 (0)