This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +41
-2
lines changed
compiler/rustc_passes/src
src/test/ui/lint/dead-code Expand file tree Collapse file tree 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> {
290290 }
291291
292292 fn visit_pat(&mut self, pat: &'tcx hir::Pat<'tcx>) {
293+ self.in_pat = true;
293294 match pat.kind {
294295 PatKind::Struct(ref path, ref fields, _) => {
295296 let res = self.typeck_results().qpath_res(path, pat.hir_id);
@@ -302,7 +303,6 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
302303 _ => (),
303304 }
304305
305- self.in_pat = true;
306306 intravisit::walk_pat(self, pat);
307307 self.in_pat = false;
308308 }
Original file line number Diff line number Diff line change 11// check-pass
22
3- #![deny (dead_code)]
3+ #![warn (dead_code)]
44
55const TLC: usize = 4;
66
@@ -28,8 +28,27 @@ impl Foo<Y> for X {
2828 }
2929}
3030
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+
3149fn main() {
3250 let s = [0,1,2,3];
3351 s.doit();
3452 X::foo();
53+ E::A.check();
3554}
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