diff --git a/library/core/src/ops/deref.rs b/library/core/src/ops/deref.rs index 305861ea7b698..c715f43b29814 100644 --- a/library/core/src/ops/deref.rs +++ b/library/core/src/ops/deref.rs @@ -141,7 +141,7 @@ pub const trait Deref: PointeeSized { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "deref_target"] #[lang = "deref_target"] - type Target: ?Sized; + type Target: PointeeSized; /// Dereferences the value. #[must_use] @@ -152,7 +152,7 @@ pub const trait Deref: PointeeSized { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] -impl const Deref for &T { +impl const Deref for &T { type Target = T; #[rustc_diagnostic_item = "noop_method_deref"] @@ -162,11 +162,11 @@ impl const Deref for &T { } #[stable(feature = "rust1", since = "1.0.0")] -impl !DerefMut for &T {} +impl !DerefMut for &T {} #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] -impl const Deref for &mut T { +impl const Deref for &mut T { type Target = T; fn deref(&self) -> &T { @@ -276,7 +276,7 @@ pub const trait DerefMut: [const] Deref + PointeeSized { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] -impl const DerefMut for &mut T { +impl const DerefMut for &mut T { fn deref_mut(&mut self) -> &mut T { self } @@ -296,10 +296,10 @@ impl const DerefMut for &mut T { pub unsafe trait DerefPure: PointeeSized {} #[unstable(feature = "deref_pure_trait", issue = "87121")] -unsafe impl DerefPure for &T {} +unsafe impl DerefPure for &T {} #[unstable(feature = "deref_pure_trait", issue = "87121")] -unsafe impl DerefPure for &mut T {} +unsafe impl DerefPure for &mut T {} /// Indicates that a struct can be used as a method receiver. /// That is, a type can use this type as a type of `self`, like this: @@ -371,11 +371,11 @@ pub trait Receiver: PointeeSized { #[rustc_diagnostic_item = "receiver_target"] #[lang = "receiver_target"] #[unstable(feature = "arbitrary_self_types", issue = "44874")] - type Target: ?Sized; + type Target: PointeeSized; } #[unstable(feature = "arbitrary_self_types", issue = "44874")] -impl Receiver for P +impl Receiver for P where P: Deref, { diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index 81c2dabf0d1d8..c0300e6966248 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -926,7 +926,7 @@ use crate::ops::{CoerceUnsized, Deref, DerefMut, DerefPure, DispatchFromDyn, Leg use crate::{ cell::{RefCell, UnsafeCell}, future::Future, - marker::PhantomPinned, + marker::{PhantomPinned, PointeeSized}, mem, ptr, }; use crate::{cmp, fmt}; @@ -1516,7 +1516,7 @@ impl Pin { } } -impl<'a, T: ?Sized> Pin<&'a T> { +impl<'a, T: PointeeSized> Pin<&'a T> { /// Constructs a new pin by mapping the interior value. /// /// For example, if you wanted to get a `Pin` of a field of something, @@ -1535,7 +1535,7 @@ impl<'a, T: ?Sized> Pin<&'a T> { #[stable(feature = "pin", since = "1.33.0")] pub unsafe fn map_unchecked(self, func: F) -> Pin<&'a U> where - U: ?Sized, + U: PointeeSized, F: FnOnce(&T) -> &U, { let pointer = &*self.pointer; @@ -1572,7 +1572,7 @@ impl<'a, T: ?Sized> Pin<&'a T> { } } -impl<'a, T: ?Sized> Pin<&'a mut T> { +impl<'a, T: PointeeSized> Pin<&'a mut T> { /// Converts this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime. #[inline(always)] #[must_use = "`self` will be dropped if the result is not used"] @@ -1639,7 +1639,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> { #[stable(feature = "pin", since = "1.33.0")] pub unsafe fn map_unchecked_mut(self, func: F) -> Pin<&'a mut U> where - U: ?Sized, + U: PointeeSized, F: FnOnce(&mut T) -> &mut U, { // SAFETY: the caller is responsible for not moving the @@ -1652,7 +1652,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> { } } -impl Pin<&'static T> { +impl Pin<&'static T> { /// Gets a pinning reference from a `&'static` reference. /// /// This is safe because `T` is borrowed immutably for the `'static` lifetime, which @@ -1666,7 +1666,7 @@ impl Pin<&'static T> { } } -impl Pin<&'static mut T> { +impl Pin<&'static mut T> { /// Gets a pinning mutable reference from a static mutable reference. /// /// This is safe because `T` is borrowed for the `'static` lifetime, which @@ -1719,7 +1719,7 @@ mod helper { #[rustc_const_unstable(feature = "const_convert", issue = "143773")] #[rustc_diagnostic_item = "PinDerefMutHelper"] pub const trait PinDerefMutHelper { - type Target: ?Sized; + type Target: super::PointeeSized; fn deref_mut(&mut self) -> &mut Self::Target; } @@ -1847,19 +1847,19 @@ where pub unsafe trait PinCoerceUnsized {} #[stable(feature = "pin", since = "1.33.0")] -unsafe impl<'a, T: ?Sized> PinCoerceUnsized for &'a T {} +unsafe impl<'a, T: PointeeSized> PinCoerceUnsized for &'a T {} #[stable(feature = "pin", since = "1.33.0")] -unsafe impl<'a, T: ?Sized> PinCoerceUnsized for &'a mut T {} +unsafe impl<'a, T: PointeeSized> PinCoerceUnsized for &'a mut T {} #[stable(feature = "pin", since = "1.33.0")] unsafe impl PinCoerceUnsized for Pin {} #[stable(feature = "pin", since = "1.33.0")] -unsafe impl PinCoerceUnsized for *const T {} +unsafe impl PinCoerceUnsized for *const T {} #[stable(feature = "pin", since = "1.33.0")] -unsafe impl PinCoerceUnsized for *mut T {} +unsafe impl PinCoerceUnsized for *mut T {} /// Constructs a [Pin]<[&mut] T>, by pinning a `value: T` locally. ///