about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorChinedu Francis Nwafili <frankie.nwafili@gmail.com>2023-08-03 09:50:00 -0400
committerChinedu Francis Nwafili <frankie.nwafili@gmail.com>2023-08-08 08:34:09 -0400
commitb56a04975c8c77b14a474fe3b38573872a065971 (patch)
tree62db517ee0776bec7d0295a558ac205a1b80fa1b /compiler
parentc115ec11d2087050dc12c5c83959979aa98bb3e5 (diff)
downloadrust-b56a04975c8c77b14a474fe3b38573872a065971.tar.gz
rust-b56a04975c8c77b14a474fe3b38573872a065971.zip
Fix multiple `expect` attribs in impl block
Closes #114416
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_errors/src/lib.rs4
-rw-r--r--compiler/rustc_passes/src/dead.rs7
2 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index 3d1639db4af..0449d538709 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -1263,6 +1263,10 @@ impl Handler {
         std::mem::take(&mut self.inner.borrow_mut().fulfilled_expectations)
     }
 
+    pub fn insert_fulfilled_expectation(&self, expectation_id: LintExpectationId) {
+        self.inner.borrow_mut().fulfilled_expectations.insert(expectation_id);
+    }
+
     pub fn flush_delayed(&self) {
         let mut inner = self.inner.lock();
         let bugs = std::mem::replace(&mut inner.delayed_span_bugs, Vec::new());
diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs
index fbe6fc3bee4..39ecc9919d3 100644
--- a/compiler/rustc_passes/src/dead.rs
+++ b/compiler/rustc_passes/src/dead.rs
@@ -814,6 +814,13 @@ impl<'tcx> DeadVisitor<'tcx> {
             }
         };
 
+        for id in &dead_codes[1..] {
+            let hir = self.tcx.hir().local_def_id_to_hir_id(*id);
+            let lint_level = self.tcx.lint_level_at_node(lint::builtin::DEAD_CODE, hir).0;
+            if let Some(expectation_id) = lint_level.get_expectation_id() {
+                self.tcx.sess.diagnostic().insert_fulfilled_expectation(expectation_id);
+            }
+        }
         self.tcx.emit_spanned_lint(
             lint,
             tcx.hir().local_def_id_to_hir_id(first_id),