about summary refs log tree commit diff
path: root/compiler/rustc_errors
diff options
context:
space:
mode:
authorxFrednet <xFrednet@gmail.com>2021-11-24 21:57:38 +0100
committerxFrednet <xFrednet@gmail.com>2022-03-02 17:46:09 +0100
commitaa2a0a83d9aa241bbce62797b1c2140c79389ef5 (patch)
treedc2c1b7bc4fd22babfca14c571d03a4632998460 /compiler/rustc_errors
parenta9bf9eaef5165067414b33777a2c924e42aab5aa (diff)
downloadrust-aa2a0a83d9aa241bbce62797b1c2140c79389ef5.tar.gz
rust-aa2a0a83d9aa241bbce62797b1c2140c79389ef5.zip
Expect each lint in attribute individually (RFC-2383)
Diffstat (limited to 'compiler/rustc_errors')
-rw-r--r--compiler/rustc_errors/src/lib.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index 0fd057f434b..b53208a6e5d 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -942,10 +942,16 @@ impl Handler {
 
         let mut inner = self.inner.borrow_mut();
         for mut diag in diags.into_iter() {
-            if let Some(unstable_id) = diag.level.get_expectation_id() {
-                if let Some(stable_id) = unstable_to_stable.get(&unstable_id) {
-                    diag.level = Level::Expect(*stable_id);
-                    inner.fulfilled_expectations.insert(*stable_id);
+            if let Some(mut unstable_id) = diag.level.get_expectation_id() {
+                let lint_index = unstable_id.get_lint_index();
+
+                // The unstable to stable map only maps the unstable it to a stable id
+                // the lint index is manually transferred here.
+                unstable_id.set_lint_index(None);
+                if let Some(mut stable_id) = unstable_to_stable.get(&unstable_id).map(|id| *id) {
+                    stable_id.set_lint_index(lint_index);
+                    diag.level = Level::Expect(stable_id);
+                    inner.fulfilled_expectations.insert(stable_id);
                 }
             }
 
@@ -1007,7 +1013,7 @@ impl HandlerInner {
         // 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 Level::Expect(LintExpectationId::Unstable(_)) = diagnostic.level {
+        if let Level::Expect(LintExpectationId::Unstable { .. }) = diagnostic.level {
             self.unstable_expect_diagnostics.push(diagnostic.clone());
             return;
         }