Skip to content

Commit aec4bdb

Browse files
committed
Move Expect/ForceWarning handling into the match.
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.
1 parent c81767e commit aec4bdb

File tree

1 file changed

+17
-15
lines changed
  • compiler/rustc_errors/src

1 file changed

+17
-15
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,19 +1364,6 @@ impl DiagCtxtInner {
13641364
self.future_breakage_diagnostics.push(diagnostic.clone());
13651365
}
13661366

1367-
if let Expect(expect_id) | ForceWarning(Some(expect_id)) = diagnostic.level {
1368-
// The `LintExpectationId` can be stable or unstable depending on when it was created.
1369-
// Diagnostics created before the definition of `HirId`s are unstable and can not yet
1370-
// be stored. Instead, they are buffered until the `LintExpectationId` is replaced by
1371-
// a stable one by the `LintLevelsBuilder`.
1372-
if let LintExpectationId::Unstable { .. } = expect_id {
1373-
self.unstable_expect_diagnostics.push(diagnostic);
1374-
return None;
1375-
}
1376-
self.suppressed_expected_diag = true;
1377-
self.fulfilled_expectations.insert(expect_id.normalize());
1378-
}
1379-
13801367
match diagnostic.level {
13811368
Fatal | Error if self.treat_next_err_as_bug() => {
13821369
// `Fatal` and `Error` can be promoted to `Bug`.
@@ -1418,10 +1405,25 @@ impl DiagCtxtInner {
14181405
}
14191406
return None;
14201407
}
1421-
Allow | Expect(_) => {
1422-
TRACK_DIAGNOSTIC(diagnostic, &mut |_| None);
1408+
Allow => {
14231409
return None;
14241410
}
1411+
Expect(expect_id) | ForceWarning(Some(expect_id)) => {
1412+
// Diagnostics created before the definition of `HirId`s are
1413+
// unstable and can not yet be stored. Instead, they are
1414+
// buffered until the `LintExpectationId` is replaced by a
1415+
// stable one by the `LintLevelsBuilder`.
1416+
if let LintExpectationId::Unstable { .. } = expect_id {
1417+
self.unstable_expect_diagnostics.push(diagnostic);
1418+
return None;
1419+
}
1420+
self.fulfilled_expectations.insert(expect_id.normalize());
1421+
if let Expect(_) = diagnostic.level {
1422+
TRACK_DIAGNOSTIC(diagnostic, &mut |_| None);
1423+
self.suppressed_expected_diag = true;
1424+
return None;
1425+
}
1426+
}
14251427
_ => {}
14261428
}
14271429

0 commit comments

Comments
 (0)