]> git.lizzy.rs Git - rust.git/blob - tests/target/struct_lits.rs
Tidy up and pass tests
[rust.git] / tests / target / struct_lits.rs
1 // rustfmt-normalize_comments: true
2 // rustfmt-wrap_comments: true
3 // rustfmt-error_on_line_overflow: false
4 // Struct literal expressions.
5
6 fn main() {
7     let x = Bar;
8
9     // Comment
10     let y = Foo { a: x };
11
12     Foo {
13         a: foo(), // comment
14         // comment
15         b: bar(),
16         ..something
17     };
18
19     Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo { a: f(), b: b() };
20
21     Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo {
22         a: f(),
23         b: b(),
24     };
25
26     Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo {
27         // Comment
28         a: foo(), // Comment
29         // Comment
30         b: bar(), // Comment
31     };
32
33     Foo { a: Bar, b: f() };
34
35     Quux {
36         x: if cond {
37             bar();
38         },
39         y: baz(),
40     };
41
42     A {
43         // Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit
44         // amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante
45         // hendrerit. Donec et mollis dolor.
46         first: item(),
47         // Praesent et diam eget libero egestas mattis sit amet vitae augue.
48         // Nam tincidunt congue enim, ut porta lorem lacinia consectetur.
49         second: Item,
50     };
51
52     Some(Data::MethodCallData(MethodCallData {
53         span: sub_span.unwrap(),
54         scope: self.enclosing_scope(id),
55         ref_id: def_id,
56         decl_id: Some(decl_id),
57     }));
58
59     Diagram {
60         //                 o        This graph demonstrates how
61         //                / \       significant whitespace is
62         //               o   o      preserved.
63         //              /|\   \
64         //             o o o   o
65         graph: G,
66     }
67 }
68
69 fn matcher() {
70     TagTerminatedByteMatcher {
71         matcher: ByteMatcher {
72             pattern: b"<HTML",
73             mask: b"\xFF\xDF\xDF\xDF\xDF\xFF",
74         },
75     };
76 }
77
78 fn issue177() {
79     struct Foo<T> {
80         memb: T,
81     }
82     let foo = Foo::<i64> { memb: 10 };
83 }
84
85 fn issue201() {
86     let s = S { a: 0, ..b };
87 }
88
89 fn issue201_2() {
90     let s = S { a: S2 { ..c }, ..b };
91 }
92
93 fn issue278() {
94     let s = S {
95         a: 0,
96         //
97         b: 0,
98     };
99     let s1 = S {
100         a: 0,
101         // foo
102         //
103         // bar
104         b: 0,
105     };
106 }
107
108 fn struct_exprs() {
109     Foo { a: 1, b: f(2) };
110     Foo {
111         a: 1,
112         b: f(2),
113         ..g(3)
114     };
115     LoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongStruct {
116         ..base
117     };
118     IntrinsicISizesContribution {
119         content_intrinsic_sizes: IntrinsicISizes {
120             minimum_inline_size: 0,
121         },
122     };
123 }
124
125 fn issue123() {
126     Foo { a: b, c: d, e: f };
127
128     Foo {
129         a: bb,
130         c: dd,
131         e: ff,
132     };
133
134     Foo {
135         a: ddddddddddddddddddddd,
136         b: cccccccccccccccccccccccccccccccccccccc,
137     };
138 }
139
140 fn issue491() {
141     Foo {
142         guard: None,
143         arm: 0, // Comment
144     };
145
146     Foo {
147         arm: 0, // Comment
148     };
149
150     Foo {
151         a: aaaaaaaaaa,
152         b: bbbbbbbb,
153         c: cccccccccc,
154         d: dddddddddd, // a comment
155         e: eeeeeeeee,
156     };
157 }
158
159 fn issue698() {
160     Record {
161         ffffffffffffffffffffffffffields: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
162     };
163     Record {
164         ffffffffffffffffffffffffffields:
165             aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
166     }
167 }
168
169 fn issue835() {
170     MyStruct {};
171     MyStruct { /* a comment */ };
172     MyStruct {
173         // Another comment
174     };
175     MyStruct {}
176 }
177
178 fn field_init_shorthand() {
179     MyStruct { x, y, z };
180     MyStruct { x, y, z, ..base };
181     Foo {
182         aaaaaaaaaa,
183         bbbbbbbb,
184         cccccccccc,
185         dddddddddd, // a comment
186         eeeeeeeee,
187     };
188     Record {
189         ffffffffffffffffffffffffffieldsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
190     };
191 }