]> git.lizzy.rs Git - rust.git/blob - tests/ui/formatting.rs
Auto merge of #85538 - r00ster91:iterrepeat, r=Mark-Simulacrum
[rust.git] / tests / ui / formatting.rs
1 #![warn(clippy::all)]
2 #![allow(unused_variables)]
3 #![allow(unused_assignments)]
4 #![allow(clippy::if_same_then_else)]
5 #![allow(clippy::deref_addrof)]
6
7 fn foo() -> bool {
8     true
9 }
10
11 #[rustfmt::skip]
12 fn main() {
13     // weird op_eq formatting:
14     let mut a = 42;
15     a =- 35;
16     a =* &191;
17
18     let mut b = true;
19     b =! false;
20
21     // those are ok:
22     a = -35;
23     a = *&191;
24     b = !false;
25
26     // possible missing comma in an array
27     let _ = &[
28         -1, -2, -3 // <= no comma here
29         -4, -5, -6
30     ];
31     let _ = &[
32         -1, -2, -3 // <= no comma here
33         *4, -5, -6
34     ];
35
36     // those are ok:
37     let _ = &[
38         -1, -2, -3,
39         -4, -5, -6
40     ];
41     let _ = &[
42         -1, -2, -3,
43         -4, -5, -6,
44     ];
45     let _ = &[
46         1 + 2, 3 +
47         4, 5 + 6,
48     ];
49
50     // don't lint for bin op without unary equiv
51     // issue 3244
52     vec![
53         1
54         / 2,
55     ];
56     // issue 3396
57     vec![
58         true
59         | false,
60     ];
61
62     // don't lint if the indentation suggests not to
63     let _ = &[
64         1 + 2, 3
65                 - 4, 5
66     ];
67     // lint if it doesn't
68     let _ = &[
69         -1
70         -4,
71     ];
72 }