File tree 3 files changed +36
-0
lines changed
tests/ui/lint/rfc-2383-lint-reason
3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -1263,6 +1263,10 @@ impl Handler {
1263
1263
std:: mem:: take ( & mut self . inner . borrow_mut ( ) . fulfilled_expectations )
1264
1264
}
1265
1265
1266
+ pub fn insert_fulfilled_expectation ( & self , expectation_id : LintExpectationId ) {
1267
+ self . inner . borrow_mut ( ) . fulfilled_expectations . insert ( expectation_id) ;
1268
+ }
1269
+
1266
1270
pub fn flush_delayed ( & self ) {
1267
1271
let mut inner = self . inner . lock ( ) ;
1268
1272
let bugs = std:: mem:: replace ( & mut inner. delayed_span_bugs , Vec :: new ( ) ) ;
Original file line number Diff line number Diff line change @@ -814,6 +814,13 @@ impl<'tcx> DeadVisitor<'tcx> {
814
814
}
815
815
} ;
816
816
817
+ for id in & dead_codes[ 1 ..] {
818
+ let hir = self . tcx . hir ( ) . local_def_id_to_hir_id ( * id) ;
819
+ let lint_level = self . tcx . lint_level_at_node ( lint:: builtin:: DEAD_CODE , hir) . 0 ;
820
+ if let Some ( expectation_id) = lint_level. get_expectation_id ( ) {
821
+ self . tcx . sess . diagnostic ( ) . insert_fulfilled_expectation ( expectation_id) ;
822
+ }
823
+ }
817
824
self . tcx . emit_spanned_lint (
818
825
lint,
819
826
tcx. hir ( ) . local_def_id_to_hir_id ( first_id) ,
Original file line number Diff line number Diff line change
1
+ // check-pass
2
+
3
+ #![ feature( lint_reasons) ]
4
+ #![ warn( unused) ]
5
+
6
+ struct OneUnused ;
7
+ struct TwoUnused ;
8
+
9
+ impl OneUnused {
10
+ #[ expect( unused) ]
11
+ fn unused ( ) { }
12
+ }
13
+
14
+ impl TwoUnused {
15
+ #[ expect( unused) ]
16
+ fn unused1 ( ) { }
17
+
18
+ #[ expect( unused) ]
19
+ fn unused2 ( ) { }
20
+ }
21
+
22
+ fn main ( ) {
23
+ let _ = OneUnused ;
24
+ let _ = TwoUnused ;
25
+ }
You can’t perform that action at this time.
0 commit comments