]> git.lizzy.rs Git - rust.git/blob - tests/ui/formatting.rs
Adapt the *.stderr files of the ui-tests to the tool_lints
[rust.git] / tests / ui / formatting.rs
1 #![feature(tool_lints)]
2
3
4 #![warn(clippy::all)]
5 #![allow(unused_variables)]
6 #![allow(unused_assignments)]
7 #![allow(clippy::if_same_then_else)]
8 #![allow(clippy::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     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     if foo() { // the span of the above error should continue here
41     }
42
43     if foo() {
44     }
45     else
46     if foo() { // the span of the above error should continue here
47     }
48
49     // those are ok:
50     if foo() {
51     }
52     if foo() {
53     }
54
55     if foo() {
56     } else if foo() {
57     }
58
59     if foo() {
60     }
61     else if foo() {
62     }
63
64     if foo() {
65     }
66     else if
67     foo() {}
68
69     // weird op_eq formatting:
70     let mut a = 42;
71     a =- 35;
72     a =* &191;
73
74     let mut b = true;
75     b =! false;
76
77     // those are ok:
78     a = -35;
79     a = *&191;
80     b = !false;
81
82     // possible missing comma in an array
83     let _ = &[
84         -1, -2, -3 // <= no comma here
85         -4, -5, -6
86     ];
87     let _ = &[
88         -1, -2, -3 // <= no comma here
89         *4, -5, -6
90     ];
91
92     // those are ok:
93     let _ = &[
94         -1, -2, -3,
95         -4, -5, -6
96     ];
97     let _ = &[
98         -1, -2, -3,
99         -4, -5, -6,
100     ];
101     let _ = &[
102         1 + 2, 3 +
103         4, 5 + 6,
104     ];
105 }