about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-04-28 13:12:14 +0200
committerGitHub <noreply@github.com>2020-04-28 13:12:14 +0200
commit2b5325dbff4021f64181199eaa6d9d34139ce42f (patch)
treea7b9155ef3e52eb624b2dadad836038d59e55a8e /src/librustc_errors
parent5aebbe9ea270df05806964b02b68a25baa22f1d8 (diff)
parent3fe280451bcc7dc2a2debf71a4d5747df0f0e0fd (diff)
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
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/lib.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index 151241fdb0b..e4a560e434a 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -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);
         }