]> git.lizzy.rs Git - rust.git/blob - tests/ui/suspicious_else_formatting.rs
Handle imports which are nested directly
[rust.git] / tests / ui / suspicious_else_formatting.rs
1 #![warn(clippy::suspicious_else_formatting)]
2
3 fn foo() -> bool {
4     true
5 }
6
7 #[rustfmt::skip]
8 fn main() {
9     // weird `else` formatting:
10     if foo() {
11     } {
12     }
13
14     if foo() {
15     } if foo() {
16     }
17
18     let _ = { // if as the last expression
19         let _ = 0;
20
21         if foo() {
22         } if foo() {
23         }
24         else {
25         }
26     };
27
28     let _ = { // if in the middle of a block
29         if foo() {
30         } if foo() {
31         }
32         else {
33         }
34
35         let _ = 0;
36     };
37
38     if foo() {
39     } else
40     {
41     }
42
43     if foo() {
44     }
45     else
46     {
47     }
48
49     if foo() {
50     } else
51     if foo() { // the span of the above error should continue here
52     }
53
54     if foo() {
55     }
56     else
57     if foo() { // the span of the above error should continue here
58     }
59
60     // those are ok:
61     if foo() {
62     }
63     {
64     }
65
66     if foo() {
67     } else {
68     }
69
70     if foo() {
71     }
72     else {
73     }
74
75     if foo() {
76     }
77     if foo() {
78     }
79 }