-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
6 changed files
with
299 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
Oops, something went wrong.