Skip to content

Commit

Permalink
Rollup merge of #87761 - rusticstuff:rustc_error_overflow, r=Mark-Sim…
Browse files Browse the repository at this point in the history
…ulacrum

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 #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.
  • Loading branch information
JohnTitor authored Aug 6, 2021
2 parents 352ad62 + 5ff06fb commit 3b0e797
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,7 @@ impl Session {
{
let old_count = self.err_count();
let result = f();
let errors = self.err_count() - old_count;
if errors == 0 { Ok(result) } else { Err(ErrorReported) }
if self.err_count() == old_count { Ok(result) } else { Err(ErrorReported) }
}
pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
self.diagnostic().span_warn(sp, msg)
Expand Down

0 comments on commit 3b0e797

Please sign in to comment.