summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/source/issue-5488.rs
blob: d361632e29efd4ca41b639c1553437738b1da358 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// rustfmt-use_field_init_shorthand: true

struct MyStruct(u32);
struct AnotherStruct {
    a: u32,
}

fn main() {
    // Since MyStruct is a tuple struct, it should not be shorthanded to
    // MyStruct { 0 } even if use_field_init_shorthand is enabled.
    let instance = MyStruct { 0: 0 };

    // Since AnotherStruct is not a tuple struct, the shorthand should
    // apply.
    let a = 10;
    let instance = AnotherStruct { a: a };
}