1
Fork 0

Lint on invalid UnsafeCell::raw_get with invalid_reference_casting lint

This commit is contained in:
Urgau 2023-08-24 12:04:40 +02:00
parent 9bd60a60ce
commit 89800a27fc
5 changed files with 117 additions and 25 deletions

View file

@ -2131,6 +2131,7 @@ impl<T: ?Sized> UnsafeCell<T> {
#[inline(always)]
#[stable(feature = "unsafe_cell_raw_get", since = "1.56.0")]
#[rustc_const_stable(feature = "unsafe_cell_raw_get", since = "1.56.0")]
#[rustc_diagnostic_item = "unsafe_cell_raw_get"]
pub const fn raw_get(this: *const Self) -> *mut T {
// We can just cast the pointer from `UnsafeCell<T>` to `T` because of
// #[repr(transparent)]. This exploits std's special status, there is