]> git.lizzy.rs Git - rust.git/blob - tests/target/expr-block.rs
Test fallout
[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];
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,
109         yyyyyyyyyyyyyyyyyyyyyyyyyyy,
110         zzzzzzzzzzzzzzzzz,
111         q,
112     ];
113
114     [1 + 3, 4, 5, 6, 7, 7, fncall::<Vec<_>>(3 - 1)]
115 }
116
117 fn function_calls() {
118     let items = itemize_list(
119         context.codemap,
120         args.iter(),
121         ")",
122         |item| item.span.lo,
123         |item| item.span.hi,
124         |item| {
125             item.rewrite(
126                 context,
127                 Shape {
128                     width: remaining_width,
129                     ..nested_shape
130                 },
131             )
132         },
133         span.lo,
134         span.hi,
135     );
136
137     itemize_list(
138         context.codemap,
139         args.iter(),
140         ")",
141         |item| item.span.lo,
142         |item| item.span.hi,
143         |item| {
144             item.rewrite(
145                 context,
146                 Shape {
147                     width: remaining_width,
148                     ..nested_shape
149                 },
150             )
151         },
152         span.lo,
153         span.hi,
154     )
155 }
156
157 fn macros() {
158     baz!(
159         do_not,
160         add,
161         trailing,
162         commas,
163         inside,
164         of,
165         function,
166         like,
167         macros,
168         even,
169         if_they,
170         are,
171         long
172     );
173
174     baz!(one_item_macro_which_is_also_loooooooooooooooooooooooooooooooooooooooooooooooong);
175
176     let _ = match option {
177         None => {
178             baz!(
179                 function,
180                 like,
181                 macro_as,
182                 expression,
183                 which,
184                 is,
185                 loooooooooooooooong
186             )
187         }
188         Some(p) => baz!(one_item_macro_as_expression_which_is_also_loooooooooooooooong),
189     };
190 }