Skip to content

Commit 59eb3db

Browse files
committed
use Box::into_raw
1 parent 959693f commit 59eb3db

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tests/compile-fail/ptr_offset_int_plus_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// error-pattern: pointer value as raw bytes
22

33
fn main() {
4-
let ptr = &mut *Box::new(0u32) as *mut u32;
4+
let ptr = Box::into_raw(Box::new(0u32));
55
// Can't start with an integer pointer and get to something usable
66
unsafe {
77
let _ = (1 as *mut u8).offset(ptr as isize);

tests/compile-fail/ptr_wrapping_offset_int_plus_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// error-pattern: pointer value as raw bytes
22

33
fn main() {
4-
let ptr = &mut *Box::new(0u32) as *mut u32;
4+
let ptr = Box::into_raw(Box::new(0u32));
55
// Can't start with an integer pointer and get to something usable
66
let ptr = (1 as *mut u8).wrapping_offset(ptr as isize);
77
let _ = unsafe { *ptr };

0 commit comments

Comments
 (0)