]> git.lizzy.rs Git - rust.git/blob - tests/ui/formatting.rs
typos: coma -> comma
[rust.git] / tests / ui / formatting.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3
4 #![deny(clippy)]
5 #![allow(unused_variables)]
6 #![allow(unused_assignments)]
7 #![allow(if_same_then_else)]
8 #![allow(deref_addrof)]
9
10 fn foo() -> bool { true }
11
12 fn main() {
13     // weird `else if` formatting:
14     if foo() {
15     } if foo() {
16
17
18     }
19
20     let _ = { // if as the last expression
21         let _ = 0;
22
23         if foo() {
24         } if foo() {
25
26
27         }
28         else {
29         }
30     };
31
32     let _ = { // if in the middle of a block
33         if foo() {
34         } if foo() {
35
36
37         }
38         else {
39         }
40
41         let _ = 0;
42     };
43
44     if foo() {
45     } else
46
47
48     if foo() { // the span of the above error should continue here
49     }
50
51     if foo() {
52     }
53
54
55     else
56     if foo() { // the span of the above error should continue here
57     }
58
59     // those are ok:
60     if foo() {
61     }
62     if foo() {
63     }
64
65     if foo() {
66     } else if foo() {
67     }
68
69     if foo() {
70     }
71     else if foo() {
72     }
73
74     if foo() {
75     }
76
77     else if
78
79     foo() {}
80
81     // weird op_eq formatting:
82     let mut a = 42;
83     a =- 35;
84
85
86     a =* &191;
87
88
89
90     let mut b = true;
91     b =! false;
92
93
94
95     // those are ok:
96     a = -35;
97     a = *&191;
98     b = !false;
99
100     // possible missing comma in an array
101     let _ = &[
102         -1, -2, -3 // <= no comma here
103
104
105         -4, -5, -6
106     ];
107     let _ = &[
108         -1, -2, -3 // <= no comma here
109
110
111         *4, -5, -6
112     ];
113
114     // those are ok:
115     let _ = &[
116         -1, -2, -3,
117         -4, -5, -6
118     ];
119     let _ = &[
120         -1, -2, -3,
121         -4, -5, -6,
122     ];
123     let _ = &[
124         1 + 2, 3 +
125         4, 5 + 6,
126     ];
127 }