]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/ifs_same_cond.rs
Sync portable-simd to rust-lang/portable-simd@72df4c45056a8bc0d1b3f06fdc828722177f0763
[rust.git] / src / tools / clippy / tests / ui / ifs_same_cond.rs
1 #![warn(clippy::ifs_same_cond)]
2 #![allow(clippy::if_same_then_else, clippy::comparison_chain)] // all empty blocks
3
4 fn ifs_same_cond() {
5     let a = 0;
6     let b = false;
7
8     if b {
9     } else if b {
10         //~ ERROR ifs same condition
11     }
12
13     if a == 1 {
14     } else if a == 1 {
15         //~ ERROR ifs same condition
16     }
17
18     if 2 * a == 1 {
19     } else if 2 * a == 2 {
20     } else if 2 * a == 1 {
21         //~ ERROR ifs same condition
22     } else if a == 1 {
23     }
24
25     // See #659
26     if cfg!(feature = "feature1-659") {
27         1
28     } else if cfg!(feature = "feature2-659") {
29         2
30     } else {
31         3
32     };
33
34     let mut v = vec![1];
35     if v.pop() == None {
36         // ok, functions
37     } else if v.pop() == None {
38     }
39
40     if v.len() == 42 {
41         // ok, functions
42     } else if v.len() == 42 {
43     }
44 }
45
46 fn main() {}