diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-02-13 14:20:41 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-03-01 13:34:31 +1100 |
| commit | aec4bdb0a2802765ee90e4f59c9173f94f28f2eb (patch) | |
| tree | 19829bc6c1a8033fc9c955fe71a83305f9469ac9 /compiler/rustc_errors | |
| parent | c81767e7cb06dacc7bb9a5ec0b746b0c774e0aa1 (diff) | |
| download | rust-aec4bdb0a2802765ee90e4f59c9173f94f28f2eb.tar.gz rust-aec4bdb0a2802765ee90e4f59c9173f94f28f2eb.zip | |
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.
Diffstat (limited to 'compiler/rustc_errors')
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index e0735208709..0f399906291 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -1364,19 +1364,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`. @@ -1418,10 +1405,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; + } + } _ => {} } |
