]> git.proxmox.com Git - rustc.git/blame - src/test/ui/pattern/usefulness/match-arm-statics.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / pattern / usefulness / match-arm-statics.rs
CommitLineData
32a655c1
SL
1#![allow(dead_code)]
2#![deny(unreachable_patterns)]
3
1a4d82fc
JJ
4use self::Direction::{North, East, South, West};
5
32a655c1 6#[derive(PartialEq, Eq)]
1a4d82fc
JJ
7struct NewBool(bool);
8
32a655c1 9#[derive(PartialEq, Eq)]
1a4d82fc
JJ
10enum Direction {
11 North,
12 East,
13 South,
14 West
15}
16
17const TRUE_TRUE: (bool, bool) = (true, true);
18
1a4d82fc
JJ
19fn unreachable_1() {
20 match (true, false) {
21 TRUE_TRUE => (),
22 (false, false) => (),
23 (false, true) => (),
24 (true, false) => (),
25 (true, true) => ()
26 //~^ ERROR unreachable pattern
27 }
28}
29
30const NONE: Option<Direction> = None;
31const EAST: Direction = East;
32
1a4d82fc
JJ
33fn unreachable_2() {
34 match Some(Some(North)) {
35 Some(NONE) => (),
36 Some(Some(North)) => (),
37 Some(Some(EAST)) => (),
38 Some(Some(South)) => (),
39 Some(Some(West)) => (),
40 Some(Some(East)) => (),
41 //~^ ERROR unreachable pattern
42 None => ()
43 }
44}
45
46const NEW_FALSE: NewBool = NewBool(false);
47struct Foo {
48 bar: Option<Direction>,
49 baz: NewBool
50}
51
1a4d82fc
JJ
52fn unreachable_3() {
53 match (Foo { bar: Some(EAST), baz: NewBool(true) }) {
54 Foo { bar: None, baz: NewBool(true) } => (),
55 Foo { bar: _, baz: NEW_FALSE } => (),
56 Foo { bar: Some(West), baz: NewBool(true) } => (),
57 Foo { bar: Some(South), .. } => (),
58 Foo { bar: Some(EAST), .. } => (),
59 Foo { bar: Some(North), baz: NewBool(true) } => (),
60 Foo { bar: Some(EAST), baz: NewBool(false) } => ()
61 //~^ ERROR unreachable pattern
62 }
63}
64
65fn main() {
1a4d82fc
JJ
66 unreachable_1();
67 unreachable_2();
68 unreachable_3();
69}