Skip to content

Commit 690805a

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 b693146 commit 690805a

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
@@ -1311,19 +1311,6 @@ impl DiagCtxtInner {
13111311
self.future_breakage_diagnostics.push(diagnostic.clone());
13121312
}
13131313

1314-
if let Expect(expect_id) | ForceWarning(Some(expect_id)) = diagnostic.level {
1315-
// The `LintExpectationId` can be stable or unstable depending on when it was created.
1316-
// Diagnostics created before the definition of `HirId`s are unstable and can not yet
1317-
// be stored. Instead, they are buffered until the `LintExpectationId` is replaced by
1318-
// a stable one by the `LintLevelsBuilder`.
1319-
if let LintExpectationId::Unstable { .. } = expect_id {
1320-
self.unstable_expect_diagnostics.push(diagnostic);
1321-
return None;
1322-
}
1323-
self.suppressed_expected_diag = true;
1324-
self.fulfilled_expectations.insert(expect_id.normalize());
1325-
}
1326-
13271314
match diagnostic.level {
13281315
Fatal | Error if self.treat_next_err_as_bug() => {
13291316
// `Fatal` and `Error` can be promoted to `Bug`.
@@ -1364,10 +1351,25 @@ impl DiagCtxtInner {
13641351
}
13651352
return None;
13661353
}
1367-
Allow | Expect(_) => {
1368-
TRACK_DIAGNOSTIC(diagnostic, &mut |_| None);
1354+
Allow => {
13691355
return None;
13701356
}
1357+
Expect(expect_id) | ForceWarning(Some(expect_id)) => {
1358+
// Diagnostics created before the definition of `HirId`s are
1359+
// unstable and can not yet be stored. Instead, they are
1360+
// buffered until the `LintExpectationId` is replaced by a
1361+
// stable one by the `LintLevelsBuilder`.
1362+
if let LintExpectationId::Unstable { .. } = expect_id {
1363+
self.unstable_expect_diagnostics.push(diagnostic);
1364+
return None;
1365+
}
1366+
self.fulfilled_expectations.insert(expect_id.normalize());
1367+
if let Expect(_) = diagnostic.level {
1368+
TRACK_DIAGNOSTIC(diagnostic, &mut |_| None);
1369+
self.suppressed_expected_diag = true;
1370+
return None;
1371+
}
1372+
}
13711373
_ => {}
13721374
}
13731375

0 commit comments

Comments
 (0)