about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2020-04-24 01:03:20 -0300
committerSantiago Pastorino <spastorino@gmail.com>2020-04-27 09:14:30 -0300
commit230e40644b5c112228a0b43d07fda552133f00b8 (patch)
treea293f7ae16f6aff56a3ad447cabee8e2311ceea4 /src/librustc_errors
parent66f7a5d92f5adb9053bf66e0bf8f6d31d404870d (diff)
Fix off by one error for delay_span_bug
delay_span_bug bumps error_count after checking treat_err_as_bug
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);
         }