Auto merge of #13454 - samueltardieu:push-ymnkzlqloptz, r=xFrednet
Use correct std/core prefix in lint output changelog: none I was waiting for #13452 to be merged before sending this one. `std` is used instead of `core` when appropriate in messages.
This commit is contained in:
commit
f444012c4c
6 changed files with 299 additions and 47 deletions
|
|
@ -1,44 +1,44 @@
|
|||
fn main() {
|
||||
unsafe {
|
||||
let _slice: &[usize] = std::slice::from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
let _slice: &[usize] = std::slice::from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
|
||||
let _slice: &[usize] = std::slice::from_raw_parts_mut(core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
let _slice: &[usize] = std::slice::from_raw_parts_mut(std::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
|
||||
std::ptr::copy::<usize>(core::ptr::NonNull::dangling().as_ptr(), std::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
std::ptr::copy::<usize>(std::ptr::NonNull::dangling().as_ptr(), core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
std::ptr::copy::<usize>(std::ptr::NonNull::dangling().as_ptr(), std::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
std::ptr::copy::<usize>(std::ptr::NonNull::dangling().as_ptr(), std::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
|
||||
std::ptr::copy_nonoverlapping::<usize>(core::ptr::NonNull::dangling().as_ptr(), std::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
std::ptr::copy_nonoverlapping::<usize>(std::ptr::NonNull::dangling().as_ptr(), core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
std::ptr::copy_nonoverlapping::<usize>(std::ptr::NonNull::dangling().as_ptr(), std::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
std::ptr::copy_nonoverlapping::<usize>(std::ptr::NonNull::dangling().as_ptr(), std::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
|
||||
struct A; // zero sized struct
|
||||
assert_eq!(std::mem::size_of::<A>(), 0);
|
||||
|
||||
let _a: A = std::ptr::read(core::ptr::NonNull::dangling().as_ptr());
|
||||
let _a: A = std::ptr::read(core::ptr::NonNull::dangling().as_ptr());
|
||||
let _a: A = std::ptr::read(std::ptr::NonNull::dangling().as_ptr());
|
||||
let _a: A = std::ptr::read(std::ptr::NonNull::dangling().as_ptr());
|
||||
|
||||
let _a: A = std::ptr::read_unaligned(core::ptr::NonNull::dangling().as_ptr());
|
||||
let _a: A = std::ptr::read_unaligned(core::ptr::NonNull::dangling().as_ptr());
|
||||
let _a: A = std::ptr::read_unaligned(std::ptr::NonNull::dangling().as_ptr());
|
||||
let _a: A = std::ptr::read_unaligned(std::ptr::NonNull::dangling().as_ptr());
|
||||
|
||||
let _a: A = std::ptr::read_volatile(core::ptr::NonNull::dangling().as_ptr());
|
||||
let _a: A = std::ptr::read_volatile(core::ptr::NonNull::dangling().as_ptr());
|
||||
let _a: A = std::ptr::read_volatile(std::ptr::NonNull::dangling().as_ptr());
|
||||
let _a: A = std::ptr::read_volatile(std::ptr::NonNull::dangling().as_ptr());
|
||||
|
||||
let _a: A = std::ptr::replace(core::ptr::NonNull::dangling().as_ptr(), A);
|
||||
let _a: A = std::ptr::replace(std::ptr::NonNull::dangling().as_ptr(), A);
|
||||
let _slice: *const [usize] = std::ptr::slice_from_raw_parts(std::ptr::null_mut(), 0); // shouldn't lint
|
||||
let _slice: *const [usize] = std::ptr::slice_from_raw_parts_mut(std::ptr::null_mut(), 0);
|
||||
|
||||
std::ptr::swap::<A>(core::ptr::NonNull::dangling().as_ptr(), &mut A);
|
||||
std::ptr::swap::<A>(&mut A, core::ptr::NonNull::dangling().as_ptr());
|
||||
std::ptr::swap::<A>(std::ptr::NonNull::dangling().as_ptr(), &mut A);
|
||||
std::ptr::swap::<A>(&mut A, std::ptr::NonNull::dangling().as_ptr());
|
||||
|
||||
std::ptr::swap_nonoverlapping::<A>(core::ptr::NonNull::dangling().as_ptr(), &mut A, 0);
|
||||
std::ptr::swap_nonoverlapping::<A>(&mut A, core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
std::ptr::swap_nonoverlapping::<A>(std::ptr::NonNull::dangling().as_ptr(), &mut A, 0);
|
||||
std::ptr::swap_nonoverlapping::<A>(&mut A, std::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
|
||||
std::ptr::write(core::ptr::NonNull::dangling().as_ptr(), A);
|
||||
std::ptr::write(std::ptr::NonNull::dangling().as_ptr(), A);
|
||||
|
||||
std::ptr::write_unaligned(core::ptr::NonNull::dangling().as_ptr(), A);
|
||||
std::ptr::write_unaligned(std::ptr::NonNull::dangling().as_ptr(), A);
|
||||
|
||||
std::ptr::write_volatile(core::ptr::NonNull::dangling().as_ptr(), A);
|
||||
std::ptr::write_volatile(std::ptr::NonNull::dangling().as_ptr(), A);
|
||||
|
||||
std::ptr::write_bytes::<usize>(core::ptr::NonNull::dangling().as_ptr(), 42, 0);
|
||||
std::ptr::write_bytes::<usize>(std::ptr::NonNull::dangling().as_ptr(), 42, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: pointer must be non-null
|
|||
--> tests/ui/invalid_null_ptr_usage.rs:3:59
|
||||
|
|
||||
LL | let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::null(), 0);
|
||||
| ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
|
||||
= note: `#[deny(clippy::invalid_null_ptr_usage)]` on by default
|
||||
|
||||
|
|
@ -10,127 +10,127 @@ error: pointer must be non-null
|
|||
--> tests/ui/invalid_null_ptr_usage.rs:4:59
|
||||
|
|
||||
LL | let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::null_mut(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:6:63
|
||||
|
|
||||
LL | let _slice: &[usize] = std::slice::from_raw_parts_mut(std::ptr::null_mut(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:8:33
|
||||
|
|
||||
LL | std::ptr::copy::<usize>(std::ptr::null(), std::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
| ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:9:73
|
||||
|
|
||||
LL | std::ptr::copy::<usize>(std::ptr::NonNull::dangling().as_ptr(), std::ptr::null_mut(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:11:48
|
||||
|
|
||||
LL | std::ptr::copy_nonoverlapping::<usize>(std::ptr::null(), std::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
| ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:12:88
|
||||
|
|
||||
LL | std::ptr::copy_nonoverlapping::<usize>(std::ptr::NonNull::dangling().as_ptr(), std::ptr::null_mut(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:17:36
|
||||
|
|
||||
LL | let _a: A = std::ptr::read(std::ptr::null());
|
||||
| ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:18:36
|
||||
|
|
||||
LL | let _a: A = std::ptr::read(std::ptr::null_mut());
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:20:46
|
||||
|
|
||||
LL | let _a: A = std::ptr::read_unaligned(std::ptr::null());
|
||||
| ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:21:46
|
||||
|
|
||||
LL | let _a: A = std::ptr::read_unaligned(std::ptr::null_mut());
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:23:45
|
||||
|
|
||||
LL | let _a: A = std::ptr::read_volatile(std::ptr::null());
|
||||
| ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:24:45
|
||||
|
|
||||
LL | let _a: A = std::ptr::read_volatile(std::ptr::null_mut());
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:26:39
|
||||
|
|
||||
LL | let _a: A = std::ptr::replace(std::ptr::null_mut(), A);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:30:29
|
||||
|
|
||||
LL | std::ptr::swap::<A>(std::ptr::null_mut(), &mut A);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:31:37
|
||||
|
|
||||
LL | std::ptr::swap::<A>(&mut A, std::ptr::null_mut());
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:33:44
|
||||
|
|
||||
LL | std::ptr::swap_nonoverlapping::<A>(std::ptr::null_mut(), &mut A, 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:34:52
|
||||
|
|
||||
LL | std::ptr::swap_nonoverlapping::<A>(&mut A, std::ptr::null_mut(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:36:25
|
||||
|
|
||||
LL | std::ptr::write(std::ptr::null_mut(), A);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:38:35
|
||||
|
|
||||
LL | std::ptr::write_unaligned(std::ptr::null_mut(), A);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:40:34
|
||||
|
|
||||
LL | std::ptr::write_volatile(std::ptr::null_mut(), A);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage.rs:42:40
|
||||
|
|
||||
LL | std::ptr::write_bytes::<usize>(std::ptr::null_mut(), 42, 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: aborting due to 22 previous errors
|
||||
|
||||
|
|
|
|||
57
tests/ui/invalid_null_ptr_usage_no_std.fixed
Normal file
57
tests/ui/invalid_null_ptr_usage_no_std.fixed
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#![no_std]
|
||||
#![feature(lang_items)]
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
#[lang = "eh_personality"]
|
||||
extern "C" fn eh_personality() {}
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
let _slice: &[usize] = core::slice::from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
let _slice: &[usize] = core::slice::from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
|
||||
let _slice: &[usize] = core::slice::from_raw_parts_mut(core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
|
||||
core::ptr::copy::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
core::ptr::copy::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
|
||||
core::ptr::copy_nonoverlapping::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
core::ptr::copy_nonoverlapping::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
|
||||
struct A; // zero sized struct
|
||||
assert_eq!(core::mem::size_of::<A>(), 0);
|
||||
|
||||
let _a: A = core::ptr::read(core::ptr::NonNull::dangling().as_ptr());
|
||||
let _a: A = core::ptr::read(core::ptr::NonNull::dangling().as_ptr());
|
||||
|
||||
let _a: A = core::ptr::read_unaligned(core::ptr::NonNull::dangling().as_ptr());
|
||||
let _a: A = core::ptr::read_unaligned(core::ptr::NonNull::dangling().as_ptr());
|
||||
|
||||
let _a: A = core::ptr::read_volatile(core::ptr::NonNull::dangling().as_ptr());
|
||||
let _a: A = core::ptr::read_volatile(core::ptr::NonNull::dangling().as_ptr());
|
||||
|
||||
let _a: A = core::ptr::replace(core::ptr::NonNull::dangling().as_ptr(), A);
|
||||
let _slice: *const [usize] = core::ptr::slice_from_raw_parts(core::ptr::null_mut(), 0); // shouldn't lint
|
||||
let _slice: *const [usize] = core::ptr::slice_from_raw_parts_mut(core::ptr::null_mut(), 0);
|
||||
|
||||
core::ptr::swap::<A>(core::ptr::NonNull::dangling().as_ptr(), &mut A);
|
||||
core::ptr::swap::<A>(&mut A, core::ptr::NonNull::dangling().as_ptr());
|
||||
|
||||
core::ptr::swap_nonoverlapping::<A>(core::ptr::NonNull::dangling().as_ptr(), &mut A, 0);
|
||||
core::ptr::swap_nonoverlapping::<A>(&mut A, core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
|
||||
core::ptr::write(core::ptr::NonNull::dangling().as_ptr(), A);
|
||||
|
||||
core::ptr::write_unaligned(core::ptr::NonNull::dangling().as_ptr(), A);
|
||||
|
||||
core::ptr::write_volatile(core::ptr::NonNull::dangling().as_ptr(), A);
|
||||
|
||||
core::ptr::write_bytes::<usize>(core::ptr::NonNull::dangling().as_ptr(), 42, 0);
|
||||
}
|
||||
}
|
||||
57
tests/ui/invalid_null_ptr_usage_no_std.rs
Normal file
57
tests/ui/invalid_null_ptr_usage_no_std.rs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#![no_std]
|
||||
#![feature(lang_items)]
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
#[lang = "eh_personality"]
|
||||
extern "C" fn eh_personality() {}
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
let _slice: &[usize] = core::slice::from_raw_parts(core::ptr::null(), 0);
|
||||
let _slice: &[usize] = core::slice::from_raw_parts(core::ptr::null_mut(), 0);
|
||||
|
||||
let _slice: &[usize] = core::slice::from_raw_parts_mut(core::ptr::null_mut(), 0);
|
||||
|
||||
core::ptr::copy::<usize>(core::ptr::null(), core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
core::ptr::copy::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::null_mut(), 0);
|
||||
|
||||
core::ptr::copy_nonoverlapping::<usize>(core::ptr::null(), core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
core::ptr::copy_nonoverlapping::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::null_mut(), 0);
|
||||
|
||||
struct A; // zero sized struct
|
||||
assert_eq!(core::mem::size_of::<A>(), 0);
|
||||
|
||||
let _a: A = core::ptr::read(core::ptr::null());
|
||||
let _a: A = core::ptr::read(core::ptr::null_mut());
|
||||
|
||||
let _a: A = core::ptr::read_unaligned(core::ptr::null());
|
||||
let _a: A = core::ptr::read_unaligned(core::ptr::null_mut());
|
||||
|
||||
let _a: A = core::ptr::read_volatile(core::ptr::null());
|
||||
let _a: A = core::ptr::read_volatile(core::ptr::null_mut());
|
||||
|
||||
let _a: A = core::ptr::replace(core::ptr::null_mut(), A);
|
||||
let _slice: *const [usize] = core::ptr::slice_from_raw_parts(core::ptr::null_mut(), 0); // shouldn't lint
|
||||
let _slice: *const [usize] = core::ptr::slice_from_raw_parts_mut(core::ptr::null_mut(), 0);
|
||||
|
||||
core::ptr::swap::<A>(core::ptr::null_mut(), &mut A);
|
||||
core::ptr::swap::<A>(&mut A, core::ptr::null_mut());
|
||||
|
||||
core::ptr::swap_nonoverlapping::<A>(core::ptr::null_mut(), &mut A, 0);
|
||||
core::ptr::swap_nonoverlapping::<A>(&mut A, core::ptr::null_mut(), 0);
|
||||
|
||||
core::ptr::write(core::ptr::null_mut(), A);
|
||||
|
||||
core::ptr::write_unaligned(core::ptr::null_mut(), A);
|
||||
|
||||
core::ptr::write_volatile(core::ptr::null_mut(), A);
|
||||
|
||||
core::ptr::write_bytes::<usize>(core::ptr::null_mut(), 42, 0);
|
||||
}
|
||||
}
|
||||
136
tests/ui/invalid_null_ptr_usage_no_std.stderr
Normal file
136
tests/ui/invalid_null_ptr_usage_no_std.stderr
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:16:60
|
||||
|
|
||||
LL | let _slice: &[usize] = core::slice::from_raw_parts(core::ptr::null(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
|
||||
= note: `#[deny(clippy::invalid_null_ptr_usage)]` on by default
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:17:60
|
||||
|
|
||||
LL | let _slice: &[usize] = core::slice::from_raw_parts(core::ptr::null_mut(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:19:64
|
||||
|
|
||||
LL | let _slice: &[usize] = core::slice::from_raw_parts_mut(core::ptr::null_mut(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:21:34
|
||||
|
|
||||
LL | core::ptr::copy::<usize>(core::ptr::null(), core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:22:75
|
||||
|
|
||||
LL | core::ptr::copy::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::null_mut(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:24:49
|
||||
|
|
||||
LL | core::ptr::copy_nonoverlapping::<usize>(core::ptr::null(), core::ptr::NonNull::dangling().as_ptr(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:25:90
|
||||
|
|
||||
LL | core::ptr::copy_nonoverlapping::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::null_mut(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:30:37
|
||||
|
|
||||
LL | let _a: A = core::ptr::read(core::ptr::null());
|
||||
| ^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:31:37
|
||||
|
|
||||
LL | let _a: A = core::ptr::read(core::ptr::null_mut());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:33:47
|
||||
|
|
||||
LL | let _a: A = core::ptr::read_unaligned(core::ptr::null());
|
||||
| ^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:34:47
|
||||
|
|
||||
LL | let _a: A = core::ptr::read_unaligned(core::ptr::null_mut());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:36:46
|
||||
|
|
||||
LL | let _a: A = core::ptr::read_volatile(core::ptr::null());
|
||||
| ^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:37:46
|
||||
|
|
||||
LL | let _a: A = core::ptr::read_volatile(core::ptr::null_mut());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:39:40
|
||||
|
|
||||
LL | let _a: A = core::ptr::replace(core::ptr::null_mut(), A);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:43:30
|
||||
|
|
||||
LL | core::ptr::swap::<A>(core::ptr::null_mut(), &mut A);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:44:38
|
||||
|
|
||||
LL | core::ptr::swap::<A>(&mut A, core::ptr::null_mut());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:46:45
|
||||
|
|
||||
LL | core::ptr::swap_nonoverlapping::<A>(core::ptr::null_mut(), &mut A, 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:47:53
|
||||
|
|
||||
LL | core::ptr::swap_nonoverlapping::<A>(&mut A, core::ptr::null_mut(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:49:26
|
||||
|
|
||||
LL | core::ptr::write(core::ptr::null_mut(), A);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:51:36
|
||||
|
|
||||
LL | core::ptr::write_unaligned(core::ptr::null_mut(), A);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:53:35
|
||||
|
|
||||
LL | core::ptr::write_volatile(core::ptr::null_mut(), A);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: pointer must be non-null
|
||||
--> tests/ui/invalid_null_ptr_usage_no_std.rs:55:41
|
||||
|
|
||||
LL | core::ptr::write_bytes::<usize>(core::ptr::null_mut(), 42, 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
||||
|
||||
error: aborting due to 22 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue