parent
c115ec11d2
commit
b56a04975c
3 changed files with 36 additions and 0 deletions
|
@ -1263,6 +1263,10 @@ impl Handler {
|
||||||
std::mem::take(&mut self.inner.borrow_mut().fulfilled_expectations)
|
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) {
|
pub fn flush_delayed(&self) {
|
||||||
let mut inner = self.inner.lock();
|
let mut inner = self.inner.lock();
|
||||||
let bugs = std::mem::replace(&mut inner.delayed_span_bugs, Vec::new());
|
let bugs = std::mem::replace(&mut inner.delayed_span_bugs, Vec::new());
|
||||||
|
|
|
@ -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(
|
self.tcx.emit_spanned_lint(
|
||||||
lint,
|
lint,
|
||||||
tcx.hir().local_def_id_to_hir_id(first_id),
|
tcx.hir().local_def_id_to_hir_id(first_id),
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
// check-pass
|
||||||
|
|
||||||
|
#![feature(lint_reasons)]
|
||||||
|
#![warn(unused)]
|
||||||
|
|
||||||
|
struct OneUnused;
|
||||||
|
struct TwoUnused;
|
||||||
|
|
||||||
|
impl OneUnused {
|
||||||
|
#[expect(unused)]
|
||||||
|
fn unused() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TwoUnused {
|
||||||
|
#[expect(unused)]
|
||||||
|
fn unused1(){}
|
||||||
|
|
||||||
|
#[expect(unused)]
|
||||||
|
fn unused2(){}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _ = OneUnused;
|
||||||
|
let _ = TwoUnused;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue