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 3
3
fn main() {
4
4
let _slice: &[usize] = unsafe { std::slice::from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0) };
5
5
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) };
6
8
}
Original file line number Diff line number Diff line change 3
3
fn main ( ) {
4
4
let _slice: & [ usize ] = unsafe { std:: slice:: from_raw_parts ( std:: ptr:: null ( ) , 0 ) } ;
5
5
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 ) } ;
6
8
}
Original file line number Diff line number Diff line change @@ -12,5 +12,17 @@ error: pointer must be non-null
12
12
LL | let _slice: &[usize] = unsafe { std::slice::from_raw_parts(core::ptr::null(), 0) };
13
13
| ^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
14
14
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
16
28
You can’t perform that action at this time.
0 commit comments