Skip to content

Commit 5ff06fb

Browse files
committed
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. Fixes #84219.
1 parent 49ca3d9 commit 5ff06fb

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)