]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/match_bool.rs
Auto merge of #97944 - nikic:freebsd-update, r=Mark-Simulacrum
[rust.git] / src / tools / clippy / tests / ui / match_bool.rs
1 #![deny(clippy::match_bool)]
2
3 fn match_bool() {
4     let test: bool = true;
5
6     match test {
7         true => 0,
8         false => 42,
9     };
10
11     let option = 1;
12     match option == 1 {
13         true => 1,
14         false => 0,
15     };
16
17     match test {
18         true => (),
19         false => {
20             println!("Noooo!");
21         },
22     };
23
24     match test {
25         false => {
26             println!("Noooo!");
27         },
28         _ => (),
29     };
30
31     match test && test {
32         false => {
33             println!("Noooo!");
34         },
35         _ => (),
36     };
37
38     match test {
39         false => {
40             println!("Noooo!");
41         },
42         true => {
43             println!("Yes!");
44         },
45     };
46
47     // Not linted
48     match option {
49         1..=10 => 1,
50         11..=20 => 2,
51         _ => 3,
52     };
53
54     // Don't lint
55     let _ = match test {
56         #[cfg(feature = "foo")]
57         true if option == 5 => 10,
58         true => 0,
59         false => 1,
60     };
61 }
62
63 fn main() {}