]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/match_wildcard_for_single_variants.fixed
Rollup merge of #78769 - est31:remove_lifetimes, r=KodrAus
[rust.git] / src / tools / clippy / tests / ui / match_wildcard_for_single_variants.fixed
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         Foo::C => {},
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         Color::Blue => {},
35     }
36
37     // check exhaustive wild
38     match color {
39         Color::Red => {},
40         Color::Green => {},
41         Color::Rgb(..) => {},
42         Color::Blue => {},
43     }
44     match color {
45         Color::Red => {},
46         Color::Green => {},
47         Color::Rgb(_, _, _) => {},
48         Color::Blue => {},
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 }