]> git.lizzy.rs Git - rust.git/blob - tests/target/structs.rs
make rustfmt-normalize_comments false by default
[rust.git] / tests / target / structs.rs
1 // rustfmt-normalize_comments: true
2 // rustfmt-wrap_comments: true
3
4 /// A Doc comment
5 #[AnAttribute]
6 pub struct Foo {
7     #[rustfmt_skip]
8     f :   SomeType, // Comment beside a field
9     f: SomeType, // Comment beside a field
10     // Comment on a field
11     #[AnAttribute]
12     g: SomeOtherType,
13     /// A doc comment on a field
14     h: AThirdType,
15     pub i: TypeForPublicField,
16 }
17
18 struct Bar;
19
20 struct NewType(Type, OtherType);
21
22 struct NewInt<T: Copy>(pub i32, SomeType /* inline comment */, T /* sup */);
23
24 struct Qux<'a,
25            N: Clone + 'a,
26            E: Clone + 'a,
27            G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
28            W: Write + Copy>
29 (
30     AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Comment
31     BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
32     #[AnAttr]
33     // Comment
34     /// Testdoc
35     G,
36     pub W,
37 );
38
39 struct Tuple(// Comment 1
40              AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
41              // Comment 2
42              BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB);
43
44 // With a where clause and generics.
45 pub struct Foo<'a, Y: Baz>
46     where X: Whatever
47 {
48     f: SomeType, // Comment beside a field
49 }
50
51 struct Baz {
52     a: A, // Comment A
53     b: B, // Comment B
54     c: C, // Comment C
55 }
56
57 struct Baz {
58     a: A, // Comment A
59
60     b: B, // Comment B
61
62     c: C, // Comment C
63 }
64
65 struct Baz {
66     a: A,
67
68     b: B,
69     c: C,
70
71     d: D,
72 }
73
74 struct Baz {
75     // Comment A
76     a: A,
77
78     // Comment B
79     b: B,
80     // Comment C
81     c: C,
82 }
83
84 // Will this be a one-liner?
85 struct Tuple(A /* Comment */, B);
86
87 pub struct State<F: FnMut() -> time::Timespec> {
88     now: F,
89 }
90
91 pub struct State<F: FnMut() -> ()> {
92     now: F,
93 }
94
95 pub struct State<F: FnMut()> {
96     now: F,
97 }
98
99 struct Palette {
100     /// A map of indizes in the palette to a count of pixels in approximately
101     /// that color
102     foo: i32,
103 }
104
105 // Splitting a single line comment into a block previously had a misalignment
106 // when the field had attributes
107 struct FieldsWithAttributes {
108     // Pre Comment
109     #[rustfmt_skip] pub host:String, /* Post comment BBBBBBBBBBBBBB BBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBB
110                                       * BBBBBBBBBBBBBBBBB BBBBBBBBBBB */
111     // Another pre comment
112     #[attr1]
113     #[attr2]
114     pub id: usize, /* CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC
115                     * CCCCCCCCCCCCCC CCCCCCCCCCCC */
116 }
117
118 struct Deep {
119     deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep: node::Handle<IdRef<'id, Node<K, V>>,
120                                                                          Type,
121                                                                          NodeType>,
122 }
123
124 struct Foo<T>(T);
125 struct Foo<T>(T)
126     where T: Copy,
127           T: Eq;
128 struct Foo<T>(TTTTTTTTTTTTTTTTT,
129               UUUUUUUUUUUUUUUUUUUUUUUU,
130               TTTTTTTTTTTTTTTTTTT,
131               UUUUUUUUUUUUUUUUUUU);
132 struct Foo<T>(TTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT) where T: PartialEq;
133 struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTTTT)
134     where T: PartialEq;
135 struct Foo<T>(TTTTTTTTTTTTTTTTT,
136               UUUUUUUUUUUUUUUUUUUUUUUU,
137               TTTTTTTTTTTTTTTTTTT,
138               UUUUUUUUUUUUUUUUUUU)
139     where T: PartialEq;
140 struct Foo<T>(TTTTTTTTTTTTTTTTT, // Foo
141               UUUUUUUUUUUUUUUUUUUUUUUU, // Bar
142               // Baz
143               TTTTTTTTTTTTTTTTTTT,
144               // Qux (FIXME #572 - doc comment)
145               UUUUUUUUUUUUUUUUUUU);
146
147 mod m {
148     struct X<T>
149         where T: Sized
150     {
151         a: T,
152     }
153 }
154
155 struct Foo<T>(TTTTTTTTTTTTTTTTTTT,
156               /// Qux
157               UUUUUUUUUUUUUUUUUUU);
158
159 struct Issue677 {
160     pub ptr: *const libc::c_void,
161     pub trace: fn(obj: *const libc::c_void, tracer: *mut JSTracer),
162 }
163
164 struct Foo {}
165 struct Foo {}
166 struct Foo {
167     // comment
168 }
169 struct Foo {
170     // trailing space ->
171 }
172 struct Foo { /* comment */ }
173 struct Foo();