]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | // run-rustfix |
2 | ||
3 | #![warn(clippy::match_wildcard_for_single_variants)] | |
4 | #![allow(dead_code)] | |
5 | ||
6 | enum Foo { | |
7 | A, | |
8 | B, | |
9 | C, | |
10 | } | |
11 | ||
12 | enum Color { | |
13 | Red, | |
14 | Green, | |
15 | Blue, | |
16 | Rgb(u8, u8, u8), | |
17 | } | |
18 | ||
19 | fn main() { | |
20 | let f = Foo::A; | |
21 | match f { | |
22 | Foo::A => {}, | |
23 | Foo::B => {}, | |
24 | _ => {}, | |
25 | } | |
26 | ||
27 | let color = Color::Red; | |
28 | ||
29 | // check exhaustive bindings | |
30 | match color { | |
31 | Color::Red => {}, | |
32 | Color::Green => {}, | |
33 | Color::Rgb(_r, _g, _b) => {}, | |
34 | _ => {}, | |
35 | } | |
36 | ||
37 | // check exhaustive wild | |
38 | match color { | |
39 | Color::Red => {}, | |
40 | Color::Green => {}, | |
41 | Color::Rgb(..) => {}, | |
42 | _ => {}, | |
43 | } | |
44 | match color { | |
45 | Color::Red => {}, | |
46 | Color::Green => {}, | |
47 | Color::Rgb(_, _, _) => {}, | |
48 | _ => {}, | |
49 | } | |
50 | ||
51 | // shouldn't lint as there is one missing variant | |
52 | // and one that isn't exhaustively covered | |
53 | match color { | |
54 | Color::Red => {}, | |
55 | Color::Green => {}, | |
56 | Color::Rgb(255, _, _) => {}, | |
57 | _ => {}, | |
58 | } | |
59 | } |