mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-30 21:16:27 +03:00
remove memory leak from run-pass test
This commit is contained in:
@@ -3,7 +3,10 @@ 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
|
||||
let ret = *ptr;
|
||||
// unleak memory
|
||||
std::mem::transmute::<*const i32, Option<Box<i32>>>(ptr);
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user