Rollup merge of #151365 - RalfJung:unsafe-unpin-opsem, r=BoxyUwU
UnsafePinned: implement opsem effects of UnsafeUnpin This implements the next step for https://github.com/rust-lang/rust/issues/125735: actually making `UnsafePinned` have special opsem effects by suppressing the `noalias` *even if* the type is wrapped in an `Unpin` wrapper. For backwards compatibility we also still keep the `Unpin` hack, i.e. a type must be both `Unpin` and `UnsafeUnpin` to get `noalias`.
This commit is contained in:
commit
33c2a6eba9
16 changed files with 123 additions and 36 deletions
|
|
@ -927,14 +927,20 @@ marker_impls! {
|
|||
/// This is part of [RFC 3467](https://rust-lang.github.io/rfcs/3467-unsafe-pinned.html), and is
|
||||
/// tracked by [#125735](https://github.com/rust-lang/rust/issues/125735).
|
||||
#[lang = "unsafe_unpin"]
|
||||
pub(crate) unsafe auto trait UnsafeUnpin {}
|
||||
#[unstable(feature = "unsafe_unpin", issue = "125735")]
|
||||
pub unsafe auto trait UnsafeUnpin {}
|
||||
|
||||
#[unstable(feature = "unsafe_unpin", issue = "125735")]
|
||||
impl<T: ?Sized> !UnsafeUnpin for UnsafePinned<T> {}
|
||||
unsafe impl<T: ?Sized> UnsafeUnpin for PhantomData<T> {}
|
||||
unsafe impl<T: ?Sized> UnsafeUnpin for *const T {}
|
||||
unsafe impl<T: ?Sized> UnsafeUnpin for *mut T {}
|
||||
unsafe impl<T: ?Sized> UnsafeUnpin for &T {}
|
||||
unsafe impl<T: ?Sized> UnsafeUnpin for &mut T {}
|
||||
marker_impls! {
|
||||
#[unstable(feature = "unsafe_unpin", issue = "125735")]
|
||||
unsafe UnsafeUnpin for
|
||||
{T: ?Sized} PhantomData<T>,
|
||||
{T: ?Sized} *const T,
|
||||
{T: ?Sized} *mut T,
|
||||
{T: ?Sized} &T,
|
||||
{T: ?Sized} &mut T,
|
||||
}
|
||||
|
||||
/// Types that do not require any pinning guarantees.
|
||||
///
|
||||
|
|
@ -1027,6 +1033,7 @@ impl !Unpin for PhantomPinned {}
|
|||
// continue working. Ideally PhantomPinned could just wrap an `UnsafePinned<()>` to get the same
|
||||
// effect, but we can't add a new field to an already stable unit struct -- that would be a breaking
|
||||
// change.
|
||||
#[unstable(feature = "unsafe_unpin", issue = "125735")]
|
||||
impl !UnsafeUnpin for PhantomPinned {}
|
||||
|
||||
marker_impls! {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ use crate::{fmt, intrinsics, ptr, ub_checks};
|
|||
issue = "none"
|
||||
)]
|
||||
pub unsafe trait ZeroablePrimitive: Sized + Copy + private::Sealed {
|
||||
#[doc(hidden)]
|
||||
/// A type like `Self` but with a niche that includes zero.
|
||||
type NonZeroInner: Sized + Copy;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue