Const Deref

This commit is contained in:
Deadbeef 2021-09-12 15:26:30 +00:00
parent 96dee2825e
commit 349ac4f6c8
No known key found for this signature in database
GPG key ID: 027DF9338862ADDD
3 changed files with 13 additions and 5 deletions

View file

@ -330,7 +330,11 @@ pub fn into_owned(self) -> <B as ToOwned>::Owned {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<B: ?Sized + ToOwned> Deref for Cow<'_, B> {
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
impl<B: ?Sized + ToOwned> const Deref for Cow<'_, B>
where
B::Owned: ~const Borrow<B>,
{
type Target = B;
fn deref(&self) -> &B {

View file

@ -145,7 +145,8 @@ pub unsafe fn drop(slot: &mut ManuallyDrop<T>) {
}
#[stable(feature = "manually_drop", since = "1.20.0")]
impl<T: ?Sized> Deref for ManuallyDrop<T> {
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
impl<T: ?Sized> const Deref for ManuallyDrop<T> {
type Target = T;
#[inline(always)]
fn deref(&self) -> &T {
@ -154,7 +155,8 @@ fn deref(&self) -> &T {
}
#[stable(feature = "manually_drop", since = "1.20.0")]
impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
impl<T: ?Sized> const DerefMut for ManuallyDrop<T> {
#[inline(always)]
fn deref_mut(&mut self) -> &mut T {
&mut self.value

View file

@ -76,7 +76,8 @@ pub trait Deref {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Deref for &T {
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
impl<T: ?Sized> const Deref for &T {
type Target = T;
#[rustc_diagnostic_item = "noop_method_deref"]
@ -89,7 +90,8 @@ fn deref(&self) -> &T {
impl<T: ?Sized> !DerefMut for &T {}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Deref for &mut T {
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
impl<T: ?Sized> const Deref for &mut T {
type Target = T;
fn deref(&self) -> &T {