summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/default_union_representation.rs
blob: 93b2d33da2cd2163f34cbc6cee5a64149d60ef48 (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
#![feature(transparent_unions)]
#![warn(clippy::default_union_representation)]

union NoAttribute {
    a: i32,
    b: u32,
}

#[repr(C)]
union ReprC {
    a: i32,
    b: u32,
}

#[repr(packed)]
union ReprPacked {
    a: i32,
    b: u32,
}

#[repr(C, packed)]
union ReprCPacked {
    a: i32,
    b: u32,
}

#[repr(C, align(32))]
union ReprCAlign {
    a: i32,
    b: u32,
}

#[repr(align(32))]
union ReprAlign {
    a: i32,
    b: u32,
}

union SingleZST {
    f0: (),
}
union ZSTsAndField1 {
    f0: u32,
    f1: (),
    f2: (),
    f3: (),
}
union ZSTsAndField2 {
    f0: (),
    f1: (),
    f2: u32,
    f3: (),
}
union ZSTAndTwoFields {
    f0: u32,
    f1: u64,
    f2: (),
}

#[repr(C)]
union CZSTAndTwoFields {
    f0: u32,
    f1: u64,
    f2: (),
}

#[repr(transparent)]
union ReprTransparent {
    a: i32,
}

#[repr(transparent)]
union ReprTransparentZST {
    a: i32,
    b: (),
}

fn main() {}