summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/source/configs/struct_field_align_threshold/20.rs
blob: 81253c460376c2339e5d8fde614f1bc69a5f3b7c (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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
// rustfmt-struct_field_align_threshold: 20
// rustfmt-normalize_comments: true
// rustfmt-wrap_comments: true
// rustfmt-error_on_line_overflow: false

struct Foo {
    x: u32,
    yy: u32, // comment
    zzz: u32,
}

pub struct Bar {
    x: u32,
    yy: u32,
    zzz: u32,

    xxxxxxx: u32,
}

fn main() {
    let foo = Foo {
        x: 0,
        yy: 1,
        zzz: 2,
    };

    let bar = Bar {
        x: 0,
        yy: 1,
        zzz: 2,

        xxxxxxx: 3,
    };
}

                                                                       /// A Doc comment
#[AnAttribute]
pub struct 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 struct Foo {
    #[doc(hidden)]
    // This will NOT get deleted!
    bar: String, // hi
}

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

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

struct Bar;

struct NewType(Type,       OtherType);

struct
NewInt     <T: Copy>(pub i32, SomeType /* inline comment */, T /* sup */


    );

struct Qux<'a,
           N: Clone + 'a,
           E: Clone + 'a,
           G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
           W: Write + Copy>
(
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Comment
    BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
    #[AnAttr]
    // Comment
    /// Testdoc
    G,
    pub W,
);

struct Tuple(/*Comment 1*/ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
             /* Comment 2   */ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,);

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

struct Baz {

    a: A,  // Comment A
    b: B, // Comment B
    c: C,   // Comment C

}

struct Baz {
    a: A,  // Comment A

    b: B, // Comment B




    c: C,   // Comment C
}

struct Baz {

    a: A,

    b: B,
    c: C,



    
    d: D

}

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

// Will this be a one-liner?
struct Tuple(
    A, //Comment
    B
);

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

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

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

struct 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
struct 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
}

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

struct Foo<T>(T);
struct Foo<T>(T) where T: Copy, T: Eq;
struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUU);
struct Foo<T>(TTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT) where T: PartialEq;
struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTTTT) where T: PartialEq;
struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUU) where T: PartialEq;
struct Foo<T>(TTTTTTTTTTTTTTTTT, // Foo
              UUUUUUUUUUUUUUUUUUUUUUUU /* Bar */,
              // Baz
              TTTTTTTTTTTTTTTTTTT,
              // Qux (FIXME #572 - doc comment)
              UUUUUUUUUUUUUUUUUUU);

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

struct Foo<T>(TTTTTTTTTTTTTTTTTTT,
              /// Qux
    UUUUUUUUUUUUUUUUUUU);

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

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


    }
struct Foo { /* comment */ }
struct Foo( /* comment */ );

struct LongStruct {
    a: A,
    the_quick_brown_fox_jumps_over_the_lazy_dog:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
}

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

struct Foo<C=()>(String);

// #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 });
}

fn main() {
    let x = Bar;

    // Comment
    let y = Foo {a: x };

    Foo { a: foo() /* comment*/, /* comment*/ b: bar(), ..something };

    Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo { a: f(), b: b(), };

    Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo { a: f(), b: b(), };

    Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo {
        // Comment
        a: foo(), // Comment
        // Comment
        b: bar(), // Comment
    };

    Foo { a:Bar,
          b:f() };

    Quux { x: if cond { bar(); }, y: baz() };

    A { 
    // Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor.
    first: item(),
        // Praesent et diam eget libero egestas mattis sit amet vitae augue.
        // Nam tincidunt congue enim, ut porta lorem lacinia consectetur.
        second: Item
    };

    Some(Data::MethodCallData(MethodCallData {
        span: sub_span.unwrap(),
        scope: self.enclosing_scope(id),
        ref_id: def_id,
        decl_id: Some(decl_id),
    }));

    Diagram { /*                 o        This graph demonstrates how                  
               *                / \       significant whitespace is           
               *               o   o      preserved.  
               *              /|\   \
               *             o o o   o */
              graph: G, }
}

fn matcher() {
    TagTerminatedByteMatcher {
        matcher: ByteMatcher {
        pattern: b"<HTML",
        mask: b"\xFF\xDF\xDF\xDF\xDF\xFF",
    },
    };
}

fn issue177() {
    struct Foo<T> { memb: T }
    let foo = Foo::<i64> { memb: 10 };
}

fn issue201() {
    let s = S{a:0, ..  b};
}

fn issue201_2() {
    let s = S{a: S2{    .. c}, ..  b};
}

fn issue278() {
    let s = S {
        a: 0,
        //       
        b: 0,
    };
    let s1 = S {
        a: 0,
        // foo
        //      
        // bar
        b: 0,
    };
}

fn struct_exprs() {
    Foo
    { a :  1, b:f( 2)};
    Foo{a:1,b:f(2),..g(3)};
    LoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongStruct { ..base };
    IntrinsicISizesContribution { content_intrinsic_sizes: IntrinsicISizes { minimum_inline_size: 0, }, };
}

fn issue123() {
    Foo { a: b, c: d, e: f };

    Foo { a: bb, c: dd, e: ff };

    Foo { a: ddddddddddddddddddddd, b: cccccccccccccccccccccccccccccccccccccc };
}

fn issue491() {
    Foo {
        guard: None,
        arm: 0, // Comment
    };

    Foo {
        arm: 0, // Comment
    };

    Foo { a: aaaaaaaaaa, b: bbbbbbbb, c: cccccccccc, d: dddddddddd, /* a comment */
      e: eeeeeeeee };
}

fn issue698() {
    Record {
        ffffffffffffffffffffffffffields: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
    };
    Record {
        ffffffffffffffffffffffffffields: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
    }
}

fn issue835() {
    MyStruct {};
    MyStruct { /* a comment */ };
    MyStruct {
        // Another comment
    };
    MyStruct {}
}

fn field_init_shorthand() {
    MyStruct { x, y, z };
    MyStruct { x, y, z, .. base };
    Foo { aaaaaaaaaa, bbbbbbbb, cccccccccc, dddddddddd, /* a comment */
        eeeeeeeee };
    Record { ffffffffffffffffffffffffffieldsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa };
}