]> git.lizzy.rs Git - rust.git/blob - tests/target/expr-block.rs
Support block indent for function calls
[rust.git] / tests / target / expr-block.rs
1 // rustfmt-array_layout: Block
2 // rustfmt-fn_call_style: Block
3 // Test expressions with block formatting.
4
5 fn arrays() {
6     [];
7     let empty = [];
8
9     let foo = [a_long_name, a_very_lng_name, a_long_name, a_very_lng_name, a_long_name];
10
11     let foo = [
12         a_long_name,
13         a_very_lng_name,
14         a_long_name,
15         a_very_lng_name,
16         a_long_name,
17         a_very_lng_name,
18         a_long_name,
19         a_very_lng_name,
20     ];
21
22     vec![
23         a_long_name,
24         a_very_lng_name,
25         a_long_name,
26         a_very_lng_name,
27         a_long_name,
28         a_very_lng_name,
29         a_very_lng_name,
30     ];
31
32     [
33         a_long_name,
34         a_very_lng_name,
35         a_long_name,
36         a_very_lng_name,
37         a_long_name,
38         a_very_lng_name,
39         a_very_lng_name,
40     ]
41 }
42
43 fn arrays() {
44     let x = [
45         0,
46         1,
47         2,
48         3,
49         4,
50         5,
51         6,
52         7,
53         8,
54         9,
55         0,
56         1,
57         2,
58         3,
59         4,
60         5,
61         6,
62         7,
63         8,
64         9,
65         0,
66         7,
67         8,
68         9,
69         0,
70         1,
71         2,
72         3,
73         4,
74         5,
75         6,
76         7,
77         8,
78         9,
79         0,
80     ];
81
82     let y = [
83         /* comment */
84         1,
85         2, /* post comment */
86         3,
87     ];
88
89     let xy = [
90         strukt {
91             test123: value_one_two_three_four,
92             turbo: coolio(),
93         },
94         /* comment  */
95         1,
96     ];
97
98     let a = WeightedChoice::new(
99         &mut [
100             Weighted { weight: x, item: 0 },
101             Weighted { weight: 1, item: 1 },
102             Weighted { weight: x, item: 2 },
103             Weighted { weight: 1, item: 3 },
104         ],
105     );
106
107     let z =
108         [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzz, q];
109
110     [1 + 3, 4, 5, 6, 7, 7, fncall::<Vec<_>>(3 - 1)]
111 }
112
113 fn function_calls() {
114     let items = itemize_list(
115         context.codemap,
116         args.iter(),
117         ")",
118         |item| item.span.lo,
119         |item| item.span.hi,
120         |item| {
121             item.rewrite(
122                 context,
123                 Shape {
124                     width: remaining_width,
125                     ..nested_shape
126                 },
127             )
128         },
129         span.lo,
130         span.hi,
131     );
132
133     itemize_list(
134         context.codemap,
135         args.iter(),
136         ")",
137         |item| item.span.lo,
138         |item| item.span.hi,
139         |item| {
140             item.rewrite(
141                 context,
142                 Shape {
143                     width: remaining_width,
144                     ..nested_shape
145                 },
146             )
147         },
148         span.lo,
149         span.hi,
150     )
151 }