We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7f6d473 commit 4da1f71Copy full SHA for 4da1f71
src/test/run-pass/repr_c_int_align.rs
@@ -18,6 +18,12 @@ enum ReprCu8 {
18
B,
19
}
20
21
+#[repr(u8)]
22
+enum Repru8 {
23
+ A(u16),
24
+ B,
25
+}
26
+
27
#[repr(C)]
28
struct ReprC {
29
tag: u8,
@@ -26,6 +32,7 @@ struct ReprC {
32
33
34
fn main() {
35
+ // Test `repr(C, u8)`.
36
let r1 = ReprC { tag: 0, padding: 0, payload: 0 };
30
37
let r2 = ReprC { tag: 0, padding: 1, payload: 1 };
31
38
@@ -36,4 +43,13 @@ fn main() {
43
(ReprCu8::A(_), ReprCu8::A(_)) => (),
44
_ => assert!(false)
45
};
46
47
+ // Test `repr(u8)`.
48
+ let t1: &Repru8 = unsafe { std::mem::transmute(&r1) };
49
+ let t2: &Repru8 = unsafe { std::mem::transmute(&r2) };
50
51
+ match (t1, t2) {
52
+ (Repru8::A(_), Repru8::A(_)) => (),
53
+ _ => assert!(false)
54
+ };
39
55
0 commit comments