Skip to content

Commit 3337105

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 3163cc8 commit 3337105

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

+17-15
Original file line numberDiff line numberDiff line change
@@ -1308,19 +1308,6 @@ impl DiagCtxtInner {
13081308
self.future_breakage_diagnostics.push(diagnostic.clone());
13091309
}
13101310

1311-
if let Expect(expect_id) | ForceWarning(Some(expect_id)) = diagnostic.level {
1312-
// The `LintExpectationId` can be stable or unstable depending on when it was created.
1313-
// Diagnostics created before the definition of `HirId`s are unstable and can not yet
1314-
// be stored. Instead, they are buffered until the `LintExpectationId` is replaced by
1315-
// a stable one by the `LintLevelsBuilder`.
1316-
if let LintExpectationId::Unstable { .. } = expect_id {
1317-
self.unstable_expect_diagnostics.push(diagnostic);
1318-
return None;
1319-
}
1320-
self.suppressed_expected_diag = true;
1321-
self.fulfilled_expectations.insert(expect_id.normalize());
1322-
}
1323-
13241311
match diagnostic.level {
13251312
Fatal | Error if self.treat_next_err_as_bug() => {
13261313
// `Fatal` and `Error` can be promoted to `Bug`.
@@ -1361,10 +1348,25 @@ impl DiagCtxtInner {
13611348
}
13621349
return None;
13631350
}
1364-
Allow | Expect(_) => {
1365-
TRACK_DIAGNOSTIC(diagnostic, &mut |_| None);
1351+
Allow => {
13661352
return None;
13671353
}
1354+
Expect(expect_id) | ForceWarning(Some(expect_id)) => {
1355+
// Diagnostics created before the definition of `HirId`s are
1356+
// unstable and can not yet be stored. Instead, they are
1357+
// buffered until the `LintExpectationId` is replaced by a
1358+
// stable one by the `LintLevelsBuilder`.
1359+
if let LintExpectationId::Unstable { .. } = expect_id {
1360+
self.unstable_expect_diagnostics.push(diagnostic);
1361+
return None;
1362+
}
1363+
self.fulfilled_expectations.insert(expect_id.normalize());
1364+
if let Expect(_) = diagnostic.level {
1365+
TRACK_DIAGNOSTIC(diagnostic, &mut |_| None);
1366+
self.suppressed_expected_diag = true;
1367+
return None;
1368+
}
1369+
}
13681370
_ => {}
13691371
}
13701372

0 commit comments

Comments
 (0)