File tree 3 files changed +41
-2
lines changed
compiler/rustc_passes/src
src/test/ui/lint/dead-code
3 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,7 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
290
290
}
291
291
292
292
fn visit_pat ( & mut self , pat : & ' tcx hir:: Pat < ' tcx > ) {
293
+ self . in_pat = true ;
293
294
match pat. kind {
294
295
PatKind :: Struct ( ref path, ref fields, _) => {
295
296
let res = self . typeck_results ( ) . qpath_res ( path, pat. hir_id ) ;
@@ -302,7 +303,6 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
302
303
_ => ( ) ,
303
304
}
304
305
305
- self . in_pat = true ;
306
306
intravisit:: walk_pat ( self , pat) ;
307
307
self . in_pat = false ;
308
308
}
Original file line number Diff line number Diff line change 1
1
// check-pass
2
2
3
- #![ deny ( dead_code) ]
3
+ #![ warn ( dead_code) ]
4
4
5
5
const TLC : usize = 4 ;
6
6
@@ -28,8 +28,27 @@ impl Foo<Y> for X {
28
28
}
29
29
}
30
30
31
+ enum E {
32
+ A ,
33
+ B , //~ WARN variant is never constructed: `B`
34
+ C , //~ WARN variant is never constructed: `C`
35
+ }
36
+
37
+ type F = E ;
38
+
39
+ impl E {
40
+ fn check ( & self ) -> bool {
41
+ match self {
42
+ Self :: A => true ,
43
+ Self :: B => false ,
44
+ F :: C => false ,
45
+ }
46
+ }
47
+ }
48
+
31
49
fn main ( ) {
32
50
let s = [ 0 , 1 , 2 , 3 ] ;
33
51
s. doit ( ) ;
34
52
X :: foo ( ) ;
53
+ E :: A . check ( ) ;
35
54
}
Original file line number Diff line number Diff line change
1
+ warning: variant is never constructed: `B`
2
+ --> $DIR/const-and-self.rs:33:5
3
+ |
4
+ LL | B,
5
+ | ^
6
+ |
7
+ note: the lint level is defined here
8
+ --> $DIR/const-and-self.rs:3:9
9
+ |
10
+ LL | #![warn(dead_code)]
11
+ | ^^^^^^^^^
12
+
13
+ warning: variant is never constructed: `C`
14
+ --> $DIR/const-and-self.rs:34:5
15
+ |
16
+ LL | C,
17
+ | ^
18
+
19
+ warning: 2 warnings emitted
20
+
You can’t perform that action at this time.
0 commit comments