Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Const Deref #88887

Merged
merged 1 commit into from
Sep 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Const Deref
fee1-dead committed Sep 15, 2021

Verified

This commit was signed with the committer’s verified signature.
commit 349ac4f6c8839c89a39d1dd9fac1fbe9a30f2626
6 changes: 5 additions & 1 deletion library/alloc/src/borrow.rs
Original file line number Diff line number Diff line change
@@ -330,7 +330,11 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
}

#[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 {
6 changes: 4 additions & 2 deletions library/core/src/mem/manually_drop.rs
Original file line number Diff line number Diff line change
@@ -145,7 +145,8 @@ impl<T: ?Sized> 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 @@ impl<T: ?Sized> Deref for ManuallyDrop<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
6 changes: 4 additions & 2 deletions library/core/src/ops/deref.rs
Original file line number Diff line number Diff line change
@@ -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 @@ impl<T: ?Sized> Deref for &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 {