1
Fork 0

Add repr(u8) to the test

This commit is contained in:
varkor 2018-05-01 18:52:27 +01:00
parent 7f6d47314b
commit 4da1f71e4b

View file

@ -18,6 +18,12 @@ enum ReprCu8 {
B,
}
#[repr(u8)]
enum Repru8 {
A(u16),
B,
}
#[repr(C)]
struct ReprC {
tag: u8,
@ -26,6 +32,7 @@ struct ReprC {
}
fn main() {
// Test `repr(C, u8)`.
let r1 = ReprC { tag: 0, padding: 0, payload: 0 };
let r2 = ReprC { tag: 0, padding: 1, payload: 1 };
@ -36,4 +43,13 @@ fn main() {
(ReprCu8::A(_), ReprCu8::A(_)) => (),
_ => assert!(false)
};
// Test `repr(u8)`.
let t1: &Repru8 = unsafe { std::mem::transmute(&r1) };
let t2: &Repru8 = unsafe { std::mem::transmute(&r2) };
match (t1, t2) {
(Repru8::A(_), Repru8::A(_)) => (),
_ => assert!(false)
};
}