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