Skip to content

Commit

Permalink
Reorder has_future_breakage handling.
Browse files Browse the repository at this point in the history
This will enable additional refactorings.
  • Loading branch information
nnethercote committed Feb 18, 2024
1 parent bb9c204 commit b693146
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,14 @@ impl DiagCtxtInner {
fn emit_diagnostic(&mut self, mut diagnostic: Diagnostic) -> Option<ErrorGuaranteed> {
assert!(diagnostic.level.can_be_top_or_sub().0);

if diagnostic.has_future_breakage() {
// Future breakages aren't emitted if they're Level::Allow,
// but they still need to be constructed and stashed below,
// so they'll trigger the must_produce_diag check.
self.suppressed_expected_diag = true;
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
Expand All @@ -1316,14 +1324,6 @@ impl DiagCtxtInner {
self.fulfilled_expectations.insert(expect_id.normalize());
}

if diagnostic.has_future_breakage() {
// Future breakages aren't emitted if they're Level::Allow,
// but they still need to be constructed and stashed below,
// so they'll trigger the must_produce_diag check.
self.suppressed_expected_diag = true;
self.future_breakage_diagnostics.push(diagnostic.clone());
}

match diagnostic.level {
Fatal | Error if self.treat_next_err_as_bug() => {
// `Fatal` and `Error` can be promoted to `Bug`.
Expand Down

0 comments on commit b693146

Please sign in to comment.