]> git.lizzy.rs Git - rust.git/blob - tests/target/structs.rs
Merge pull request #1435 from iliekturtles/line-length
[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:
121         node::Handle<IdRef<'id, Node<K, V>>, Type, 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();
174
175 struct LongStruct {
176     a: A,
177     the_quick_brown_fox_jumps_over_the_lazy_dog:
178         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
179 }
180
181 struct Deep {
182     deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
183         node::Handle<IdRef<'id, Node<Key, Value>>, Type, NodeType>,
184 }
185
186 struct Foo<C = ()>(String);