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