File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed
compiler/rustc_passes/src Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -395,6 +395,9 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
395395 self . mark_as_used_if_union ( * adt, fields) ;
396396 }
397397 }
398+ hir:: ExprKind :: Closure ( cls) => {
399+ self . insert_def_id ( cls. def_id . to_def_id ( ) ) ;
400+ }
398401 _ => ( ) ,
399402 }
400403
Original file line number Diff line number Diff line change 1+ // edition: 2021
2+
3+ #![ deny( dead_code) ]
4+
5+ pub fn foo ( ) {
6+ let closure = || {
7+ fn a ( ) { } //~ ERROR function `a` is never used
8+ } ;
9+ closure ( )
10+ }
11+
12+ pub async fn async_foo ( ) {
13+ const A : usize = 1 ; //~ ERROR constant `A` is never used
14+ }
15+
16+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: function `a` is never used
2+ --> $DIR/in-closure.rs:7:12
3+ |
4+ LL | fn a() {}
5+ | ^
6+ |
7+ note: the lint level is defined here
8+ --> $DIR/in-closure.rs:3:9
9+ |
10+ LL | #![deny(dead_code)]
11+ | ^^^^^^^^^
12+
13+ error: constant `A` is never used
14+ --> $DIR/in-closure.rs:13:11
15+ |
16+ LL | const A: usize = 1;
17+ | ^
18+
19+ error: aborting due to 2 previous errors
20+
You can’t perform that action at this time.
0 commit comments