about summary refs log tree commit diff
path: root/compiler/rustc_errors/src/lib.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-02-13 12:20:38 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-03-01 13:27:50 +1100
commitecd3718bc0b3f823b96d6949ba22f77cfbeff5c1 (patch)
tree81a1a450a17951f2b05e31b65ae0da69b6671eea /compiler/rustc_errors/src/lib.rs
parentbf62d5913a702754d46a0e9210fcf608deba63af (diff)
downloadrust-ecd3718bc0b3f823b96d6949ba22f77cfbeff5c1.tar.gz
rust-ecd3718bc0b3f823b96d6949ba22f77cfbeff5c1.zip
Inline and remove `Level::get_diagnostic_id`.
It has a single call site, and this will enable subsequent refactorings.
Diffstat (limited to 'compiler/rustc_errors/src/lib.rs')
-rw-r--r--compiler/rustc_errors/src/lib.rs13
1 files changed, 3 insertions, 10 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index ce24f1ceaac..0c8308b6b09 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -1356,17 +1356,17 @@ impl DiagCtxtInner {
     fn emit_diagnostic(&mut self, mut diagnostic: DiagInner) -> Option<ErrorGuaranteed> {
         assert!(diagnostic.level.can_be_top_or_sub().0);
 
-        if let Some(expectation_id) = diagnostic.level.get_expectation_id() {
+        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 { .. } = expectation_id {
+            if let LintExpectationId::Unstable { .. } = expect_id {
                 self.unstable_expect_diagnostics.push(diagnostic);
                 return None;
             }
             self.suppressed_expected_diag = true;
-            self.fulfilled_expectations.insert(expectation_id.normalize());
+            self.fulfilled_expectations.insert(expect_id.normalize());
         }
 
         if diagnostic.has_future_breakage() {
@@ -1794,13 +1794,6 @@ impl Level {
         matches!(*self, FailureNote)
     }
 
-    pub fn get_expectation_id(&self) -> Option<LintExpectationId> {
-        match self {
-            Expect(id) | ForceWarning(Some(id)) => Some(*id),
-            _ => None,
-        }
-    }
-
     // Can this level be used in a top-level diagnostic message and/or a
     // subdiagnostic message?
     fn can_be_top_or_sub(&self) -> (bool, bool) {