diff --git a/library/core/src/cell/lazy.rs b/library/core/src/cell/lazy.rs index 6407aba7c8119..52a1c7b657f79 100644 --- a/library/core/src/cell/lazy.rs +++ b/library/core/src/cell/lazy.rs @@ -1,6 +1,6 @@ use super::UnsafeCell; use crate::hint::unreachable_unchecked; -use crate::ops::{Deref, DerefMut}; +use crate::ops::Deref; use crate::{fmt, mem}; enum State { @@ -122,8 +122,6 @@ impl T> LazyCell { /// Forces the evaluation of this lazy value and returns a mutable reference to /// the result. /// - /// This is equivalent to the `DerefMut` impl, but is explicit. - /// /// # Examples /// /// ``` @@ -135,11 +133,9 @@ impl T> LazyCell { /// assert_eq!(*p, 92); /// *p = 44; /// assert_eq!(*lazy, 44); - /// *lazy = 55; // Using `DerefMut` - /// assert_eq!(*lazy, 55); /// ``` #[inline] - #[stable(feature = "lazy_deref_mut", since = "CURRENT_RUSTC_VERSION")] + #[unstable(feature = "lazy_get", issue = "129333")] pub fn force_mut(this: &mut LazyCell) -> &mut T { #[cold] /// # Safety @@ -286,14 +282,6 @@ impl T> Deref for LazyCell { } } -#[stable(feature = "lazy_deref_mut", since = "CURRENT_RUSTC_VERSION")] -impl T> DerefMut for LazyCell { - #[inline] - fn deref_mut(&mut self) -> &mut T { - LazyCell::force_mut(self) - } -} - #[stable(feature = "lazy_cell", since = "1.80.0")] impl Default for LazyCell { /// Creates a new lazy value using `Default` as the initializing function. diff --git a/library/std/src/sync/lazy_lock.rs b/library/std/src/sync/lazy_lock.rs index afdfec43afd36..4dbb4f6e29c00 100644 --- a/library/std/src/sync/lazy_lock.rs +++ b/library/std/src/sync/lazy_lock.rs @@ -1,7 +1,7 @@ use super::once::ExclusiveState; use crate::cell::UnsafeCell; use crate::mem::ManuallyDrop; -use crate::ops::{Deref, DerefMut}; +use crate::ops::Deref; use crate::panic::{RefUnwindSafe, UnwindSafe}; use crate::sync::Once; use crate::{fmt, ptr}; @@ -137,8 +137,6 @@ impl T> LazyLock { /// Forces the evaluation of this lazy value and returns a mutable reference to /// the result. /// - /// This is equivalent to the `DerefMut` impl, but is explicit. - /// /// # Examples /// /// ``` @@ -150,11 +148,9 @@ impl T> LazyLock { /// assert_eq!(*p, 92); /// *p = 44; /// assert_eq!(*lazy, 44); - /// *lazy = 55; // Using `DerefMut` - /// assert_eq!(*lazy, 55); /// ``` #[inline] - #[stable(feature = "lazy_deref_mut", since = "CURRENT_RUSTC_VERSION")] + #[unstable(feature = "lazy_get", issue = "129333")] pub fn force_mut(this: &mut LazyLock) -> &mut T { #[cold] /// # Safety @@ -317,14 +313,6 @@ impl T> Deref for LazyLock { } } -#[stable(feature = "lazy_deref_mut", since = "CURRENT_RUSTC_VERSION")] -impl T> DerefMut for LazyLock { - #[inline] - fn deref_mut(&mut self) -> &mut T { - LazyLock::force_mut(self) - } -} - #[stable(feature = "lazy_cell", since = "1.80.0")] impl Default for LazyLock { /// Creates a new lazy value using `Default` as the initializing function.