Skip to content

Commit 230e406

Browse files
committedApr 27, 2020
Fix off by one error for delay_span_bug
delay_span_bug bumps error_count after checking treat_err_as_bug
1 parent 66f7a5d commit 230e406

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-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
}

0 commit comments

Comments
 (0)
Please sign in to comment.