summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/target/unions.rs
blob: 8ed16b269c23098d02cf837a4682d31a125bc911 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
// rustfmt-normalize_comments: true
// rustfmt-wrap_comments: true

/// A Doc comment
#[AnAttribute]
pub union Foo {
    #[rustfmt::skip]
    f :   SomeType, // Comment beside a field
    f: SomeType, // Comment beside a field
    // Comment on a field
    #[AnAttribute]
    g: SomeOtherType,
    /// A doc comment on a field
    h: AThirdType,
    pub i: TypeForPublicField,
}

// #1029
pub union Foo {
    #[doc(hidden)]
    // This will NOT get deleted!
    bar: String, // hi
}

// #1029
union X {
    // `x` is an important number.
    #[allow(unused)] // TODO: use
    x: u32,
}

// #410
#[allow(missing_docs)]
pub union Writebatch<K: Key> {
    #[allow(dead_code)] // only used for holding the internal pointer
    writebatch: RawWritebatch,
    marker: PhantomData<K>,
}

// With a where-clause and generics.
pub union Foo<'a, Y: Baz>
where
    X: Whatever,
{
    f: SomeType, // Comment beside a field
}

union Baz {
    a: A, // Comment A
    b: B, // Comment B
    c: C, // Comment C
}

union Baz {
    a: A, // Comment A

    b: B, // Comment B

    c: C, // Comment C
}

union Baz {
    a: A,

    b: B,
    c: C,

    d: D,
}

union Baz {
    // Comment A
    a: A,

    // Comment B
    b: B,
    // Comment C
    c: C,
}

pub union State<F: FnMut() -> time::Timespec> {
    now: F,
}

pub union State<F: FnMut() -> ()> {
    now: F,
}

pub union State<F: FnMut()> {
    now: F,
}

union Palette {
    /// A map of indices in the palette to a count of pixels in approximately
    /// that color
    foo: i32,
}

// Splitting a single line comment into a block previously had a misalignment
// when the field had attributes
union FieldsWithAttributes {
    // Pre Comment
    #[rustfmt::skip] pub host:String, /* Post comment BBBBBBBBBBBBBB BBBBBBBBBBBBBBBB
                                       * BBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBB BBBBBBBBBBB */
    // Another pre comment
    #[attr1]
    #[attr2]
    pub id: usize, /* CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC
                    * CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCC CCCCCCCCCCCC */
}

union Deep {
    deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
        node::Handle<IdRef<'id, Node<K, V>>, Type, NodeType>,
}

mod m {
    union X<T>
    where
        T: Sized,
    {
        a: T,
    }
}

union Issue677 {
    pub ptr: *const libc::c_void,
    pub trace: fn(obj: *const libc::c_void, tracer: *mut JSTracer),
}

union Foo {}
union Foo {}
union Foo {
    // comment
}
union Foo {
    // trailing space ->
}
union Foo {
    // comment
}

union LongUnion {
    a: A,
    the_quick_brown_fox_jumps_over_the_lazy_dog:
        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
}

union Deep {
    deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
        node::Handle<IdRef<'id, Node<Key, Value>>, Type, NodeType>,
}

// #1364
fn foo() {
    convex_shape.set_point(0, &Vector2f { x: 400.0, y: 100.0 });
    convex_shape.set_point(1, &Vector2f { x: 500.0, y: 70.0 });
    convex_shape.set_point(2, &Vector2f { x: 450.0, y: 100.0 });
    convex_shape.set_point(3, &Vector2f { x: 580.0, y: 150.0 });
}

// Vertical alignment
union Foo {
    aaaaa: u32, // a

    b: u32,  // b
    cc: u32, // cc

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 1
    yy: u32,  // comment2
    zzz: u32, // comment3

    aaaaaa: u32, // comment4
    bb: u32,     // comment5
    // separate
    dd: u32, // comment7
    c: u32,  // comment6

    aaaaaaa: u32, /* multi
                   * line
                   * comment
                   */
    b: u32, // hi

    do_not_push_this_comment1: u32, // comment1
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 2
    please_do_not_push_this_comment3: u32, // comment3

    do_not_push_this_comment1: u32, // comment1
    // separate
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 2
    please_do_not_push_this_comment3: u32, // comment3

    do_not_push_this_comment1: u32, // comment1
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32, // 2
    // separate
    please_do_not_push_this_comment3: u32, // comment3
}