Skip to content

Commit 349ac4f

Browse files
committed
Const Deref
1 parent 96dee28 commit 349ac4f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

library/alloc/src/borrow.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,11 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
330330
}
331331

332332
#[stable(feature = "rust1", since = "1.0.0")]
333-
impl<B: ?Sized + ToOwned> Deref for Cow<'_, B> {
333+
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
334+
impl<B: ?Sized + ToOwned> const Deref for Cow<'_, B>
335+
where
336+
B::Owned: ~const Borrow<B>,
337+
{
334338
type Target = B;
335339

336340
fn deref(&self) -> &B {

library/core/src/mem/manually_drop.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ impl<T: ?Sized> ManuallyDrop<T> {
145145
}
146146

147147
#[stable(feature = "manually_drop", since = "1.20.0")]
148-
impl<T: ?Sized> Deref for ManuallyDrop<T> {
148+
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
149+
impl<T: ?Sized> const Deref for ManuallyDrop<T> {
149150
type Target = T;
150151
#[inline(always)]
151152
fn deref(&self) -> &T {
@@ -154,7 +155,8 @@ impl<T: ?Sized> Deref for ManuallyDrop<T> {
154155
}
155156

156157
#[stable(feature = "manually_drop", since = "1.20.0")]
157-
impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
158+
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
159+
impl<T: ?Sized> const DerefMut for ManuallyDrop<T> {
158160
#[inline(always)]
159161
fn deref_mut(&mut self) -> &mut T {
160162
&mut self.value

library/core/src/ops/deref.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ pub trait Deref {
7676
}
7777

7878
#[stable(feature = "rust1", since = "1.0.0")]
79-
impl<T: ?Sized> Deref for &T {
79+
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
80+
impl<T: ?Sized> const Deref for &T {
8081
type Target = T;
8182

8283
#[rustc_diagnostic_item = "noop_method_deref"]
@@ -89,7 +90,8 @@ impl<T: ?Sized> Deref for &T {
8990
impl<T: ?Sized> !DerefMut for &T {}
9091

9192
#[stable(feature = "rust1", since = "1.0.0")]
92-
impl<T: ?Sized> Deref for &mut T {
93+
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
94+
impl<T: ?Sized> const Deref for &mut T {
9395
type Target = T;
9496

9597
fn deref(&self) -> &T {

0 commit comments

Comments
 (0)