Skip to content

Commit

Permalink
Move Expect/ForceWarning handling into the match.
Browse files Browse the repository at this point in the history
Note that `self.suppressed_expected_diag` is no longer set for
`ForceWarning`, which is good. Nor is `TRACK_DIAGNOSTIC` called for
`Allow`, which is also good.
  • Loading branch information
nnethercote committed Feb 18, 2024
1 parent b693146 commit 690805a
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1311,19 +1311,6 @@ impl DiagCtxtInner {
self.future_breakage_diagnostics.push(diagnostic.clone());
}

if let Expect(expect_id) | ForceWarning(Some(expect_id)) = diagnostic.level {
// The `LintExpectationId` can be stable or unstable depending on when it was created.
// Diagnostics created before the definition of `HirId`s are unstable and can not yet
// be stored. Instead, they are buffered until the `LintExpectationId` is replaced by
// a stable one by the `LintLevelsBuilder`.
if let LintExpectationId::Unstable { .. } = expect_id {
self.unstable_expect_diagnostics.push(diagnostic);
return None;
}
self.suppressed_expected_diag = true;
self.fulfilled_expectations.insert(expect_id.normalize());
}

match diagnostic.level {
Fatal | Error if self.treat_next_err_as_bug() => {
// `Fatal` and `Error` can be promoted to `Bug`.
Expand Down Expand Up @@ -1364,10 +1351,25 @@ impl DiagCtxtInner {
}
return None;
}
Allow | Expect(_) => {
TRACK_DIAGNOSTIC(diagnostic, &mut |_| None);
Allow => {
return None;
}
Expect(expect_id) | ForceWarning(Some(expect_id)) => {
// Diagnostics created before the definition of `HirId`s are
// unstable and can not yet be stored. Instead, they are
// buffered until the `LintExpectationId` is replaced by a
// stable one by the `LintLevelsBuilder`.
if let LintExpectationId::Unstable { .. } = expect_id {
self.unstable_expect_diagnostics.push(diagnostic);
return None;
}
self.fulfilled_expectations.insert(expect_id.normalize());
if let Expect(_) = diagnostic.level {
TRACK_DIAGNOSTIC(diagnostic, &mut |_| None);
self.suppressed_expected_diag = true;
return None;
}
}
_ => {}
}

Expand Down

0 comments on commit 690805a

Please sign in to comment.