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