Lint on invalid UnsafeCell::raw_get with invalid_reference_casting lint
This commit is contained in:
parent
9bd60a60ce
commit
89800a27fc
5 changed files with 117 additions and 25 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue