]> git.lizzy.rs Git - rust.git/blob - tests/ui-internal/if_chain_style.rs
Remove all usages of `match_path`, `match_qpath` and `match_path_ast` except the...
[rust.git] / tests / ui-internal / if_chain_style.rs
1 #![warn(clippy::if_chain_style)]
2 #![allow(clippy::no_effect)]
3
4 extern crate if_chain;
5
6 use if_chain::if_chain;
7
8 fn main() {
9     if true {
10         let x = "";
11         // `if_chain!` inside `if`
12         if_chain! {
13             if true;
14             if true;
15             then {}
16         }
17     }
18     if_chain! {
19         if true
20             // multi-line AND'ed conditions
21             && false;
22         if let Some(1) = Some(1);
23         // `let` before `then`
24         let x = "";
25         then {
26             ();
27         }
28     }
29     if_chain! {
30         // single `if` condition
31         if true;
32         then {
33             let x = "";
34             // nested if
35             if true {}
36         }
37     }
38     if_chain! {
39         // starts with `let ..`
40         let x = "";
41         if let Some(1) = Some(1);
42         then {
43             let x = "";
44             let x = "";
45             // nested if_chain!
46             if_chain! {
47                 if true;
48                 if true;
49                 then {}
50             }
51         }
52     }
53 }
54
55 fn negative() {
56     if true {
57         ();
58         if_chain! {
59             if true;
60             if true;
61             then { (); }
62         }
63     }
64     if_chain! {
65         if true;
66         let x = "";
67         if true;
68         then { (); }
69     }
70     if_chain! {
71         if true;
72         if true;
73         then {
74             if true { 1 } else { 2 }
75         } else {
76             3
77         }
78     };
79     if true {
80         if_chain! {
81             if true;
82             if true;
83             then {}
84         }
85     } else if false {
86         if_chain! {
87             if true;
88             if false;
89             then {}
90         }
91     }
92 }