Skip to content

Commit 3b0e797

Browse files
authored
Rollup merge of rust-lang#87761 - rusticstuff:rustc_error_overflow, r=Mark-Simulacrum
Fix overflow in rustc happening if the `err_count()` is reduced in a stage. This can happen if stashed diagnostics are removed or replaced with fewer errors. The semantics stay the same if built without overflow checks. Fixes rust-lang#84219. Background: I came across this independently by running `RUSTFLAGS="-C overflow-checks=on" ./x.py test`. Fixing this will allow us to move on and find further overflow errors with testing or fuzzing.
2 parents 352ad62 + 5ff06fb commit 3b0e797

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

compiler/rustc_session/src/session.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,7 @@ impl Session {
450450
{
451451
let old_count = self.err_count();
452452
let result = f();
453-
let errors = self.err_count() - old_count;
454-
if errors == 0 { Ok(result) } else { Err(ErrorReported) }
453+
if self.err_count() == old_count { Ok(result) } else { Err(ErrorReported) }
455454
}
456455
pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
457456
self.diagnostic().span_warn(sp, msg)

0 commit comments

Comments
 (0)