rust/tests/run-pass/option_box_transmute_ptr.rs
Scott Olson f9c1cfa889 Remove now-useless #[miri_run] attributes.
Except for `ints.rs`, which is already handled by a pending pull request.
2016-06-17 22:52:30 -06:00

13 lines
317 B
Rust

// This tests that the size of Option<Box<i32>> is the same as *const i32.
fn option_box_deref() -> i32 {
let val = Some(Box::new(42));
unsafe {
let ptr: *const i32 = std::mem::transmute::<Option<Box<i32>>, *const i32>(val);
*ptr
}
}
fn main() {
assert_eq!(option_box_deref(), 42);
}