Skip to content

Commit

Permalink
Add repr(u8) to the test
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed May 1, 2018
1 parent 7f6d473 commit 4da1f71
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/test/run-pass/repr_c_int_align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ enum ReprCu8 {
B,
}

#[repr(u8)]
enum Repru8 {
A(u16),
B,
}

#[repr(C)]
struct ReprC {
tag: u8,
Expand All @@ -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 };

Expand All @@ -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)
};
}

0 comments on commit 4da1f71

Please sign in to comment.