diff --git a/tests/run-pass/option_box_transmute_ptr.rs b/tests/run-pass/option_box_transmute_ptr.rs index c81db8e8b235..0786db1ef895 100644 --- a/tests/run-pass/option_box_transmute_ptr.rs +++ b/tests/run-pass/option_box_transmute_ptr.rs @@ -3,7 +3,10 @@ fn option_box_deref() -> i32 { let val = Some(Box::new(42)); unsafe { let ptr: *const i32 = std::mem::transmute::>, *const i32>(val); - *ptr + let ret = *ptr; + // unleak memory + std::mem::transmute::<*const i32, Option>>(ptr); + ret } }