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