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
This commit is contained in:
Dylan DPC 2020-04-28 13:12:14 +02:00 committed by GitHub
commit 2b5325dbff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -869,7 +869,10 @@ impl HandlerInner {
}
fn delay_span_bug(&mut self, sp: impl Into<MultiSpan>, msg: &str) {
if self.treat_err_as_bug() {
// This is technically `self.treat_err_as_bug()` but `delay_span_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 self.flags.treat_err_as_bug.map(|c| self.err_count() + 1 >= c).unwrap_or(false) {
// FIXME: don't abort here if report_delayed_bugs is off
self.span_bug(sp, msg);
}

View File

@ -3,3 +3,5 @@
all:
$(RUSTC) err.rs -Z treat-err-as-bug 2>&1 \
| $(CGREP) "panicked at 'aborting due to \`-Z treat-err-as-bug=1\`'"
$(RUSTC) delay_span_bug.rs -Z treat-err-as-bug 2>&1 \
| $(CGREP) "panicked at 'aborting due to \`-Z treat-err-as-bug=1\`'"

View File

@ -0,0 +1,4 @@
#![feature(rustc_attrs)]
#[rustc_error(delay_span_bug_from_inside_query)]
fn main() {}