]> git.proxmox.com Git - rustc.git/blame - src/tools/rustfmt/tests/source/struct_lits_multiline.rs
New upstream version 1.52.1+dfsg1
[rustc.git] / src / tools / rustfmt / tests / source / struct_lits_multiline.rs
CommitLineData
f20569fa
XL
1// rustfmt-normalize_comments: true
2// rustfmt-wrap_comments: true
3// rustfmt-struct_lit_single_line: false
4
5// Struct literal expressions.
6
7fn main() {
8 let x = Bar;
9
10 // Comment
11 let y = Foo {a: x };
12
13 Foo { a: foo() /* comment*/, /* comment*/ b: bar(), ..something };
14
15 Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo { a: foo(), b: bar(), };
16
17 Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo { a: foo(), b: bar(), };
18
19 Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo {
20 // Comment
21 a: foo(), // Comment
22 // Comment
23 b: bar(), // Comment
24 };
25
26 Foo { a:Bar,
27 b:foo() };
28
29 Quux { x: if cond { bar(); }, y: baz() };
30
31 A {
32 // Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor.
33 first: item(),
34 // Praesent et diam eget libero egestas mattis sit amet vitae augue.
35 // Nam tincidunt congue enim, ut porta lorem lacinia consectetur.
36 second: Item
37 };
38
39 Some(Data::MethodCallData(MethodCallData {
40 span: sub_span.unwrap(),
41 scope: self.enclosing_scope(id),
42 ref_id: def_id,
43 decl_id: Some(decl_id),
44 }));
45
46 Diagram { /* o This graph demonstrates how
47 * / \ significant whitespace is
48 * o o preserved.
49 * /|\ \
50 * o o o o */
51 graph: G, }
52}
53
54fn matcher() {
55 TagTerminatedByteMatcher {
56 matcher: ByteMatcher {
57 pattern: b"<HTML",
58 mask: b"\xFF\xDF\xDF\xDF\xDF\xFF",
59 },
60 };
61}
62
63fn issue177() {
64 struct Foo<T> { memb: T }
65 let foo = Foo::<i64> { memb: 10 };
66}
67
68fn issue201() {
69 let s = S{a:0, .. b};
70}
71
72fn issue201_2() {
73 let s = S{a: S2{ .. c}, .. b};
74}
75
76fn issue491() {
77 Foo {
78 guard: None,
79 arm: 0, // Comment
80 };
81}