]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | struct Foo { |
2 | first: bool, | |
3 | second: Option<[usize; 4]> | |
4 | } | |
5 | ||
1a4d82fc JJ |
6 | fn struct_with_a_nested_enum_and_vector() { |
7 | match (Foo { first: true, second: None }) { | |
8 | //~^ ERROR non-exhaustive patterns: `Foo { first: false, second: Some([_, _, _, _]) }` not covered | |
9 | Foo { first: true, second: None } => (), | |
10 | Foo { first: true, second: Some(_) } => (), | |
11 | Foo { first: false, second: None } => (), | |
c34b1796 | 12 | Foo { first: false, second: Some([1, 2, 3, 4]) } => () |
1a4d82fc JJ |
13 | } |
14 | } | |
15 | ||
7453a54e SL |
16 | enum Color { |
17 | Red, | |
18 | Green, | |
19 | CustomRGBA { a: bool, r: u8, g: u8, b: u8 } | |
20 | } | |
21 | ||
22 | fn enum_with_single_missing_variant() { | |
1a4d82fc | 23 | match Color::Red { |
f2b60f7d | 24 | //~^ ERROR non-exhaustive patterns: `Color::Red` not covered |
7453a54e SL |
25 | Color::CustomRGBA { .. } => (), |
26 | Color::Green => () | |
27 | } | |
28 | } | |
29 | ||
30 | enum Direction { | |
31 | North, East, South, West | |
32 | } | |
33 | ||
34 | fn enum_with_multiple_missing_variants() { | |
35 | match Direction::North { | |
f2b60f7d | 36 | //~^ ERROR non-exhaustive patterns: `Direction::East`, `Direction::South` and `Direction::West` not covered |
7453a54e SL |
37 | Direction::North => () |
38 | } | |
39 | } | |
40 | ||
41 | enum ExcessiveEnum { | |
42 | First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth, Eleventh, Twelfth | |
43 | } | |
44 | ||
45 | fn enum_with_excessive_missing_variants() { | |
46 | match ExcessiveEnum::First { | |
f2b60f7d | 47 | //~^ ERROR `ExcessiveEnum::Second`, `ExcessiveEnum::Third`, `ExcessiveEnum::Fourth` and 8 more not covered |
7453a54e SL |
48 | |
49 | ExcessiveEnum::First => () | |
1a4d82fc JJ |
50 | } |
51 | } | |
52 | ||
53 | fn enum_struct_variant() { | |
54 | match Color::Red { | |
f2b60f7d | 55 | //~^ ERROR non-exhaustive patterns: `Color::CustomRGBA { a: true, .. }` not covered |
1a4d82fc JJ |
56 | Color::Red => (), |
57 | Color::Green => (), | |
58 | Color::CustomRGBA { a: false, r: _, g: _, b: 0 } => (), | |
59 | Color::CustomRGBA { a: false, r: _, g: _, b: _ } => () | |
60 | } | |
61 | } | |
62 | ||
63 | enum Enum { | |
64 | First, | |
65 | Second(bool) | |
66 | } | |
67 | ||
68 | fn vectors_with_nested_enums() { | |
69 | let x: &'static [Enum] = &[Enum::First, Enum::Second(false)]; | |
3157f602 | 70 | match *x { |
f2b60f7d | 71 | //~^ ERROR non-exhaustive patterns: `[Enum::Second(true), Enum::Second(false)]` not covered |
1a4d82fc JJ |
72 | [] => (), |
73 | [_] => (), | |
74 | [Enum::First, _] => (), | |
75 | [Enum::Second(true), Enum::First] => (), | |
76 | [Enum::Second(true), Enum::Second(true)] => (), | |
77 | [Enum::Second(false), _] => (), | |
416331ca | 78 | [_, _, ref tail @ .., _] => () |
1a4d82fc JJ |
79 | } |
80 | } | |
81 | ||
82 | fn missing_nil() { | |
83 | match ((), false) { | |
84 | //~^ ERROR non-exhaustive patterns: `((), false)` not covered | |
85 | ((), true) => () | |
86 | } | |
87 | } | |
88 | ||
89 | fn main() {} |