File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 33fn main() {
44 let _slice: &[usize] = unsafe { std::slice::from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0) };
55 let _slice: &[usize] = unsafe { std::slice::from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0) };
6+ let _slice: &[usize] = unsafe { std::slice::from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0) };
7+ let _slice: &[usize] = unsafe { std::slice::from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0) };
68}
Original file line number Diff line number Diff line change 33fn main ( ) {
44 let _slice: & [ usize ] = unsafe { std:: slice:: from_raw_parts ( std:: ptr:: null ( ) , 0 ) } ;
55 let _slice: & [ usize ] = unsafe { std:: slice:: from_raw_parts ( core:: ptr:: null ( ) , 0 ) } ;
6+ let _slice: & [ usize ] = unsafe { std:: slice:: from_raw_parts ( std:: ptr:: null_mut ( ) , 0 ) } ;
7+ let _slice: & [ usize ] = unsafe { std:: slice:: from_raw_parts ( core:: ptr:: null_mut ( ) , 0 ) } ;
68}
Original file line number Diff line number Diff line change @@ -12,5 +12,17 @@ error: pointer must be non-null
1212LL | let _slice: &[usize] = unsafe { std::slice::from_raw_parts(core::ptr::null(), 0) };
1313 | ^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
1414
15- error: aborting due to 2 previous errors
15+ error: pointer must be non-null
16+ --> $DIR/invalid_null_ptr_usage.rs:6:64
17+ |
18+ LL | let _slice: &[usize] = unsafe { std::slice::from_raw_parts(std::ptr::null_mut(), 0) };
19+ | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
20+
21+ error: pointer must be non-null
22+ --> $DIR/invalid_null_ptr_usage.rs:7:64
23+ |
24+ LL | let _slice: &[usize] = unsafe { std::slice::from_raw_parts(core::ptr::null_mut(), 0) };
25+ | ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
26+
27+ error: aborting due to 4 previous errors
1628
You can’t perform that action at this time.
0 commit comments