Skip to content

Commit

Permalink
Fix off by one error for delay_span_bug
Browse files Browse the repository at this point in the history
delay_span_bug bumps error_count after checking treat_err_as_bug
  • Loading branch information
spastorino committed Apr 27, 2020
1 parent 66f7a5d commit 230e406
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/librustc_errors/lib.rs
Expand Up @@ -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);
}
Expand Down

0 comments on commit 230e406

Please sign in to comment.