]> git.lizzy.rs Git - rust.git/blob - tests/target/structs.rs
Use block indent style for struct tuple
[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 // #1029
19 pub struct Foo {
20     #[doc(hidden)]
21     // This will NOT get deleted!
22     bar: String, // hi
23 }
24
25 // #1029
26 struct X {
27     // `x` is an important number.
28     #[allow(unused)] // TODO: use
29     x: u32,
30 }
31
32 // #410
33 #[allow(missing_docs)]
34 pub struct Writebatch<K: Key> {
35     #[allow(dead_code)] // only used for holding the internal pointer
36     writebatch: RawWritebatch,
37     marker: PhantomData<K>,
38 }
39
40 struct Bar;
41
42 struct NewType(Type, OtherType);
43
44 struct NewInt<T: Copy>(pub i32, SomeType /* inline comment */, T /* sup */);
45
46 struct Qux<
47     'a,
48     N: Clone + 'a,
49     E: Clone + 'a,
50     G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
51     W: Write + Copy,
52 >(
53     AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Comment
54     BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
55     #[AnAttr]
56     // Comment
57     /// Testdoc
58     G,
59     pub W,
60 );
61
62 struct Tuple(
63     // Comment 1
64     AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
65     // Comment 2
66     BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
67 );
68
69 // With a where clause and generics.
70 pub struct Foo<'a, Y: Baz>
71 where
72     X: Whatever,
73 {
74     f: SomeType, // Comment beside a field
75 }
76
77 struct Baz {
78     a: A, // Comment A
79     b: B, // Comment B
80     c: C, // Comment C
81 }
82
83 struct Baz {
84     a: A, // Comment A
85
86     b: B, // Comment B
87
88     c: C, // Comment C
89 }
90
91 struct Baz {
92     a: A,
93
94     b: B,
95     c: C,
96
97     d: D,
98 }
99
100 struct Baz {
101     // Comment A
102     a: A,
103
104     // Comment B
105     b: B,
106     // Comment C
107     c: C,
108 }
109
110 // Will this be a one-liner?
111 struct Tuple(A /* Comment */, B);
112
113 pub struct State<F: FnMut() -> time::Timespec> {
114     now: F,
115 }
116
117 pub struct State<F: FnMut() -> ()> {
118     now: F,
119 }
120
121 pub struct State<F: FnMut()> {
122     now: F,
123 }
124
125 struct Palette {
126     /// A map of indizes in the palette to a count of pixels in approximately
127     /// that color
128     foo: i32,
129 }
130
131 // Splitting a single line comment into a block previously had a misalignment
132 // when the field had attributes
133 struct FieldsWithAttributes {
134     // Pre Comment
135     #[rustfmt_skip] pub host:String, /* Post comment BBBBBBBBBBBBBB BBBBBBBBBBBBBBBB
136                                       * BBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBB BBBBBBBBBBB */
137     // Another pre comment
138     #[attr1]
139     #[attr2]
140     pub id: usize, /* CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC
141                     * CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCC CCCCCCCCCCCC */
142 }
143
144 struct Deep {
145     deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
146         node::Handle<IdRef<'id, Node<K, V>>, Type, NodeType>,
147 }
148
149 struct Foo<T>(T);
150 struct Foo<T>(T)
151 where
152     T: Copy,
153     T: Eq;
154 struct Foo<T>(
155     TTTTTTTTTTTTTTTTT,
156     UUUUUUUUUUUUUUUUUUUUUUUU,
157     TTTTTTTTTTTTTTTTTTT,
158     UUUUUUUUUUUUUUUUUUU,
159 );
160 struct Foo<T>(TTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT)
161 where
162     T: PartialEq;
163 struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTTTT)
164 where
165     T: PartialEq;
166 struct Foo<T>(
167     TTTTTTTTTTTTTTTTT,
168     UUUUUUUUUUUUUUUUUUUUUUUU,
169     TTTTTTTTTTTTTTTTTTT,
170     UUUUUUUUUUUUUUUUUUU,
171 )
172 where
173     T: PartialEq;
174 struct Foo<T>(
175     TTTTTTTTTTTTTTTTT, // Foo
176     UUUUUUUUUUUUUUUUUUUUUUUU, // Bar
177     // Baz
178     TTTTTTTTTTTTTTTTTTT,
179     // Qux (FIXME #572 - doc comment)
180     UUUUUUUUUUUUUUUUUUU,
181 );
182
183 mod m {
184     struct X<T>
185     where
186         T: Sized,
187     {
188         a: T,
189     }
190 }
191
192 struct Foo<T>(
193     TTTTTTTTTTTTTTTTTTT,
194     /// Qux
195     UUUUUUUUUUUUUUUUUUU,
196 );
197
198 struct Issue677 {
199     pub ptr: *const libc::c_void,
200     pub trace: fn(obj: *const libc::c_void, tracer: *mut JSTracer),
201 }
202
203 struct Foo {}
204 struct Foo {}
205 struct Foo {
206     // comment
207 }
208 struct Foo {
209     // trailing space ->
210 }
211 struct Foo { /* comment */ }
212 struct Foo( /* comment */ );
213
214 struct LongStruct {
215     a: A,
216     the_quick_brown_fox_jumps_over_the_lazy_dog:
217         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
218 }
219
220 struct Deep {
221     deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
222         node::Handle<IdRef<'id, Node<Key, Value>>, Type, NodeType>,
223 }
224
225 struct Foo<C = ()>(String);
226
227 // #1364
228 fn foo() {
229     convex_shape.set_point(0, &Vector2f { x: 400.0, y: 100.0 });
230     convex_shape.set_point(1, &Vector2f { x: 500.0, y: 70.0 });
231     convex_shape.set_point(2, &Vector2f { x: 450.0, y: 100.0 });
232     convex_shape.set_point(3, &Vector2f { x: 580.0, y: 150.0 });
233 }