]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
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 | // Destructuring | |
19 | fn foo() { | |
20 | S { x: 5, | |
21 | ..}; | |
22 | Struct {..} = Struct { a: 1, b: 4 }; | |
23 | Struct { a, .. } = Struct { a: 1, b: 2, c: 3}; | |
24 | TupleStruct(a,.., b) = TupleStruct(1, 2); | |
25 | TupleStruct( ..) = TupleStruct(3, 4); | |
26 | TupleStruct(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, .., bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) = TupleStruct(1, 2); | |
27 | } | |
28 | ||
29 | // #1095 | |
30 | struct S<T: /* comment */> { | |
31 | t: T, | |
32 | } | |
33 | ||
34 | // #1029 | |
35 | pub struct Foo { | |
36 | #[doc(hidden)] | |
37 | // This will NOT get deleted! | |
38 | bar: String, // hi | |
39 | } | |
40 | ||
41 | // #1029 | |
42 | struct X { | |
43 | // `x` is an important number. | |
44 | #[allow(unused)] // TODO: use | |
45 | x: u32, | |
46 | } | |
47 | ||
48 | // #410 | |
49 | #[allow(missing_docs)] | |
50 | pub struct Writebatch<K: Key> { | |
51 | #[allow(dead_code)] //only used for holding the internal pointer | |
52 | writebatch: RawWritebatch, | |
53 | marker: PhantomData<K>, | |
54 | } | |
55 | ||
56 | struct Bar; | |
57 | ||
58 | struct NewType(Type, OtherType); | |
59 | ||
60 | struct | |
61 | NewInt <T: Copy>(pub i32, SomeType /* inline comment */, T /* sup */ | |
62 | ||
63 | ||
64 | ); | |
65 | ||
66 | struct Qux<'a, | |
67 | N: Clone + 'a, | |
68 | E: Clone + 'a, | |
69 | G: Labeller<'a, N, E> + GraphWalk<'a, N, E>, | |
70 | W: Write + Copy> | |
71 | ( | |
72 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Comment | |
73 | BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB, | |
74 | #[AnAttr] | |
75 | // Comment | |
76 | /// Testdoc | |
77 | G, | |
78 | pub W, | |
79 | ); | |
80 | ||
81 | struct Tuple(/*Comment 1*/ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, | |
82 | /* Comment 2 */ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,); | |
83 | ||
84 | // With a where-clause and generics. | |
85 | pub struct Foo<'a, Y: Baz> | |
86 | where X: Whatever | |
87 | { | |
88 | f: SomeType, // Comment beside a field | |
89 | } | |
90 | ||
91 | struct Baz { | |
92 | ||
93 | a: A, // Comment A | |
94 | b: B, // Comment B | |
95 | c: C, // Comment C | |
96 | ||
97 | } | |
98 | ||
99 | struct Baz { | |
100 | a: A, // Comment A | |
101 | ||
102 | b: B, // Comment B | |
103 | ||
104 | ||
105 | ||
106 | ||
107 | c: C, // Comment C | |
108 | } | |
109 | ||
110 | struct Baz { | |
111 | ||
112 | a: A, | |
113 | ||
114 | b: B, | |
115 | c: C, | |
116 | ||
117 | ||
118 | ||
119 | ||
120 | d: D | |
121 | ||
122 | } | |
123 | ||
124 | struct Baz | |
125 | { | |
126 | // Comment A | |
127 | a: A, | |
128 | ||
129 | // Comment B | |
130 | b: B, | |
131 | // Comment C | |
132 | c: C,} | |
133 | ||
134 | // Will this be a one-liner? | |
135 | struct Tuple( | |
136 | A, //Comment | |
137 | B | |
138 | ); | |
139 | ||
140 | pub struct State<F: FnMut() -> time::Timespec> { now: F } | |
141 | ||
142 | pub struct State<F: FnMut() -> ()> { now: F } | |
143 | ||
144 | pub struct State<F: FnMut()> { now: F } | |
145 | ||
146 | struct Palette { /// A map of indices in the palette to a count of pixels in approximately that color | |
147 | foo: i32} | |
148 | ||
149 | // Splitting a single line comment into a block previously had a misalignment | |
150 | // when the field had attributes | |
151 | struct FieldsWithAttributes { | |
152 | // Pre Comment | |
153 | #[rustfmt::skip] pub host:String, // Post comment BBBBBBBBBBBBBB BBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBB BBBBBBBBBBB | |
154 | //Another pre comment | |
155 | #[attr1] | |
156 | #[attr2] pub id: usize // CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCC CCCCCCCCCCCC | |
157 | } | |
158 | ||
159 | struct Deep { | |
160 | deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep: node::Handle<IdRef<'id, Node<K, V>>, | |
161 | Type, | |
162 | NodeType>, | |
163 | } | |
164 | ||
165 | struct Foo<T>(T); | |
166 | struct Foo<T>(T) where T: Copy, T: Eq; | |
167 | struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUU); | |
168 | struct Foo<T>(TTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT) where T: PartialEq; | |
169 | struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTTTT) where T: PartialEq; | |
170 | struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUU) where T: PartialEq; | |
171 | struct Foo<T>(TTTTTTTTTTTTTTTTT, // Foo | |
172 | UUUUUUUUUUUUUUUUUUUUUUUU /* Bar */, | |
173 | // Baz | |
174 | TTTTTTTTTTTTTTTTTTT, | |
175 | // Qux (FIXME #572 - doc comment) | |
176 | UUUUUUUUUUUUUUUUUUU); | |
177 | ||
178 | mod m { | |
179 | struct X<T> where T: Sized { | |
180 | a: T, | |
181 | } | |
182 | } | |
183 | ||
184 | struct Foo<T>(TTTTTTTTTTTTTTTTTTT, | |
185 | /// Qux | |
186 | UUUUUUUUUUUUUUUUUUU); | |
187 | ||
188 | struct Issue677 { | |
189 | pub ptr: *const libc::c_void, | |
190 | pub trace: fn( obj: | |
191 | *const libc::c_void, tracer : *mut JSTracer ), | |
192 | } | |
193 | ||
194 | struct Foo {} | |
195 | struct Foo { | |
196 | } | |
197 | struct Foo { | |
198 | // comment | |
199 | } | |
200 | struct Foo { | |
201 | // trailing space -> | |
202 | ||
203 | ||
204 | } | |
205 | struct Foo { /* comment */ } | |
206 | struct Foo( /* comment */ ); | |
207 | ||
208 | struct LongStruct { | |
209 | a: A, | |
210 | the_quick_brown_fox_jumps_over_the_lazy_dog:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, | |
211 | } | |
212 | ||
213 | struct Deep { | |
214 | deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep: node::Handle<IdRef<'id, Node<Key, Value>>, | |
215 | Type, | |
216 | NodeType>, | |
217 | } | |
218 | ||
219 | struct Foo<C=()>(String); | |
220 | ||
221 | // #1364 | |
222 | fn foo() { | |
223 | convex_shape.set_point(0, &Vector2f { x: 400.0, y: 100.0 }); | |
224 | convex_shape.set_point(1, &Vector2f { x: 500.0, y: 70.0 }); | |
225 | convex_shape.set_point(2, &Vector2f { x: 450.0, y: 100.0 }); | |
226 | convex_shape.set_point(3, &Vector2f { x: 580.0, y: 150.0 }); | |
227 | } | |
228 | ||
229 | // Vertical alignment | |
230 | struct Foo { | |
231 | aaaaa: u32, // a | |
232 | ||
233 | b: u32, // b | |
234 | cc: u32, // cc | |
235 | ||
236 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 1 | |
237 | yy: u32, // comment2 | |
238 | zzz: u32, // comment3 | |
239 | ||
240 | aaaaaa: u32, // comment4 | |
241 | bb: u32, // comment5 | |
242 | // separate | |
243 | dd: u32, // comment7 | |
244 | c: u32, // comment6 | |
245 | ||
246 | aaaaaaa: u32, /* multi | |
247 | * line | |
248 | * comment | |
249 | */ | |
250 | b: u32, // hi | |
251 | ||
252 | do_not_push_this_comment1: u32, // comment1 | |
253 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 2 | |
254 | please_do_not_push_this_comment3: u32, // comment3 | |
255 | ||
256 | do_not_push_this_comment1: u32, // comment1 | |
257 | // separate | |
258 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 2 | |
259 | please_do_not_push_this_comment3: u32, // comment3 | |
260 | ||
261 | do_not_push_this_comment1: u32, // comment1 | |
262 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 2 | |
263 | // separate | |
264 | please_do_not_push_this_comment3: u32, // comment3 | |
265 | } | |
266 | ||
267 | // structs with long identifier | |
268 | struct Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong {} | |
269 | struct Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong {} | |
270 | struct Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong {} | |
271 | struct Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong { x: i32 } | |
272 | ||
273 | // structs with visibility, do not duplicate visibility (#2110). | |
274 | pub(in self) struct Foo{} | |
275 | pub(super) struct Foo{} | |
276 | pub(crate) struct Foo{} | |
277 | pub(in self) struct Foo(); | |
278 | pub(super) struct Foo(); | |
279 | pub(crate) struct Foo(); | |
280 | ||
281 | // #2125 | |
282 | pub struct ReadinessCheckRegistry(Mutex<HashMap<Arc<String>, Box<Fn() -> ReadinessCheck + Sync + Send>>>); | |
283 | ||
284 | // #2144 unit struct with generics | |
285 | struct MyBox<T:?Sized>; | |
286 | struct MyBoxx<T, S> where T: ?Sized, S: Clone; | |
287 | ||
288 | // #2208 | |
289 | struct Test { | |
290 | /// foo | |
291 | #[serde(default)] | |
292 | pub join: Vec<String>, | |
293 | #[serde(default)] pub tls: bool, | |
294 | } | |
295 | ||
296 | // #2818 | |
297 | struct Paren((i32)) where i32: Trait; | |
298 | struct Parens((i32, i32)) where i32: Trait; |