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