]> git.lizzy.rs Git - rust.git/blob - tests/target/unions.rs
Update uses of `rustfmt_skip` to `rustfmt::skip`
[rust.git] / tests / target / unions.rs
1 // rustfmt-normalize_comments: true
2 // rustfmt-wrap_comments: true
3
4 /// A Doc comment
5 #[AnAttribute]
6 pub union 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 union Foo {
20     #[doc(hidden)]
21     // This will NOT get deleted!
22     bar: String, // hi
23 }
24
25 // #1029
26 union 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 union Writebatch<K: Key> {
35     #[allow(dead_code)] // only used for holding the internal pointer
36     writebatch: RawWritebatch,
37     marker: PhantomData<K>,
38 }
39
40 // With a where clause and generics.
41 pub union Foo<'a, Y: Baz>
42 where
43     X: Whatever,
44 {
45     f: SomeType, // Comment beside a field
46 }
47
48 union Baz {
49     a: A, // Comment A
50     b: B, // Comment B
51     c: C, // Comment C
52 }
53
54 union Baz {
55     a: A, // Comment A
56
57     b: B, // Comment B
58
59     c: C, // Comment C
60 }
61
62 union Baz {
63     a: A,
64
65     b: B,
66     c: C,
67
68     d: D,
69 }
70
71 union Baz {
72     // Comment A
73     a: A,
74
75     // Comment B
76     b: B,
77     // Comment C
78     c: C,
79 }
80
81 pub union State<F: FnMut() -> time::Timespec> {
82     now: F,
83 }
84
85 pub union State<F: FnMut() -> ()> {
86     now: F,
87 }
88
89 pub union State<F: FnMut()> {
90     now: F,
91 }
92
93 union Palette {
94     /// A map of indices in the palette to a count of pixels in approximately
95     /// that color
96     foo: i32,
97 }
98
99 // Splitting a single line comment into a block previously had a misalignment
100 // when the field had attributes
101 union FieldsWithAttributes {
102     // Pre Comment
103     #[rustfmt::skip] pub host:String, /* Post comment BBBBBBBBBBBBBB BBBBBBBBBBBBBBBB
104                                        * BBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBB BBBBBBBBBBB */
105     // Another pre comment
106     #[attr1]
107     #[attr2]
108     pub id: usize, /* CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC
109                     * CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCC CCCCCCCCCCCC */
110 }
111
112 union Deep {
113     deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
114         node::Handle<IdRef<'id, Node<K, V>>, Type, NodeType>,
115 }
116
117 mod m {
118     union X<T>
119     where
120         T: Sized,
121     {
122         a: T,
123     }
124 }
125
126 union Issue677 {
127     pub ptr: *const libc::c_void,
128     pub trace: fn(obj: *const libc::c_void, tracer: *mut JSTracer),
129 }
130
131 union Foo {}
132 union Foo {}
133 union Foo {
134     // comment
135 }
136 union Foo {
137     // trailing space ->
138 }
139 union Foo {
140     // comment
141 }
142
143 union LongUnion {
144     a: A,
145     the_quick_brown_fox_jumps_over_the_lazy_dog:
146         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
147 }
148
149 union Deep {
150     deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
151         node::Handle<IdRef<'id, Node<Key, Value>>, Type, NodeType>,
152 }
153
154 // #1364
155 fn foo() {
156     convex_shape.set_point(0, &Vector2f { x: 400.0, y: 100.0 });
157     convex_shape.set_point(1, &Vector2f { x: 500.0, y: 70.0 });
158     convex_shape.set_point(2, &Vector2f { x: 450.0, y: 100.0 });
159     convex_shape.set_point(3, &Vector2f { x: 580.0, y: 150.0 });
160 }
161
162 // Vertical alignment
163 union Foo {
164     aaaaa: u32, // a
165
166     b: u32,  // b
167     cc: u32, // cc
168
169     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 1
170     yy: u32,  // comment2
171     zzz: u32, // comment3
172
173     aaaaaa: u32, // comment4
174     bb: u32,     // comment5
175     // separate
176     dd: u32, // comment7
177     c: u32,  // comment6
178
179     aaaaaaa: u32, /* multi
180                    * line
181                    * comment
182                    */
183     b: u32, // hi
184
185     do_not_push_this_comment1: u32, // comment1
186     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 2
187     please_do_not_push_this_comment3: u32, // comment3
188
189     do_not_push_this_comment1: u32, // comment1
190     // separate
191     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 2
192     please_do_not_push_this_comment3: u32, // comment3
193
194     do_not_push_this_comment1: u32, // comment1
195     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 2
196     // separate
197     please_do_not_push_this_comment3: u32, // comment3
198 }