about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJubilee Young <workingjubilee@gmail.com>2024-09-17 09:31:57 -0700
committerJubilee Young <workingjubilee@gmail.com>2024-09-18 11:39:21 -0700
commitd9cdb71497fbfcf36f6debd3fcf559c0fe3cf9ec (patch)
tree06148c0e4cc30c7a674963d9e1b934bdfcf31254
parentd0a2ca4867c15659e28ab9c3930b5df4e60afcb0 (diff)
downloadrust-d9cdb71497fbfcf36f6debd3fcf559c0fe3cf9ec.tar.gz
rust-d9cdb71497fbfcf36f6debd3fcf559c0fe3cf9ec.zip
library: Destabilize Lazy{Cell,Lock}::{force,deref}_mut
-rw-r--r--library/core/src/cell/lazy.rs17
-rw-r--r--library/core/src/lib.rs1
-rw-r--r--library/core/tests/lib.rs1
-rw-r--r--library/std/src/lib.rs1
-rw-r--r--library/std/src/sync/lazy_lock.rs17
5 files changed, 9 insertions, 28 deletions
diff --git a/library/core/src/cell/lazy.rs b/library/core/src/cell/lazy.rs
index 6407aba7c81..8c88f967aa2 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<T, F> {
@@ -122,11 +122,10 @@ impl<T, F: FnOnce() -> T> LazyCell<T, F> {
     /// 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
     ///
     /// ```
+    /// #![feature(lazy_get)]
     /// use std::cell::LazyCell;
     ///
     /// let mut lazy = LazyCell::new(|| 92);
@@ -135,11 +134,9 @@ impl<T, F: FnOnce() -> T> LazyCell<T, F> {
     /// 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<T, F>) -> &mut T {
         #[cold]
         /// # Safety
@@ -286,14 +283,6 @@ impl<T, F: FnOnce() -> T> Deref for LazyCell<T, F> {
     }
 }
 
-#[stable(feature = "lazy_deref_mut", since = "CURRENT_RUSTC_VERSION")]
-impl<T, F: FnOnce() -> T> DerefMut for LazyCell<T, F> {
-    #[inline]
-    fn deref_mut(&mut self) -> &mut T {
-        LazyCell::force_mut(self)
-    }
-}
-
 #[stable(feature = "lazy_cell", since = "1.80.0")]
 impl<T: Default> Default for LazyCell<T> {
     /// Creates a new lazy value using `Default` as the initializing function.
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index e3640627c56..86b69c18483 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -172,6 +172,7 @@
 #![feature(is_ascii_octdigit)]
 #![feature(is_val_statically_known)]
 #![feature(isqrt)]
+#![feature(lazy_get)]
 #![feature(link_cfg)]
 #![feature(offset_of_enum)]
 #![feature(panic_internals)]
diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
index 8872b4cbfd5..d824f6d203b 100644
--- a/library/core/tests/lib.rs
+++ b/library/core/tests/lib.rs
@@ -77,6 +77,7 @@
 #![feature(iterator_try_collect)]
 #![feature(iterator_try_reduce)]
 #![feature(layout_for_ptr)]
+#![feature(lazy_get)]
 #![feature(maybe_uninit_fill)]
 #![feature(maybe_uninit_uninit_array_transpose)]
 #![feature(maybe_uninit_write_slice)]
diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs
index 2530a376387..57be36fcfcb 100644
--- a/library/std/src/lib.rs
+++ b/library/std/src/lib.rs
@@ -336,6 +336,7 @@
 #![feature(hasher_prefixfree_extras)]
 #![feature(hashmap_internals)]
 #![feature(ip)]
+#![feature(lazy_get)]
 #![feature(maybe_uninit_slice)]
 #![feature(maybe_uninit_write_slice)]
 #![feature(panic_can_unwind)]
diff --git a/library/std/src/sync/lazy_lock.rs b/library/std/src/sync/lazy_lock.rs
index afdfec43afd..f6b6887cdbb 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,11 +137,10 @@ impl<T, F: FnOnce() -> T> LazyLock<T, F> {
     /// 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
     ///
     /// ```
+    /// #![feature(lazy_get)]
     /// use std::sync::LazyLock;
     ///
     /// let mut lazy = LazyLock::new(|| 92);
@@ -150,11 +149,9 @@ impl<T, F: FnOnce() -> T> LazyLock<T, F> {
     /// 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<T, F>) -> &mut T {
         #[cold]
         /// # Safety
@@ -317,14 +314,6 @@ impl<T, F: FnOnce() -> T> Deref for LazyLock<T, F> {
     }
 }
 
-#[stable(feature = "lazy_deref_mut", since = "CURRENT_RUSTC_VERSION")]
-impl<T, F: FnOnce() -> T> DerefMut for LazyLock<T, F> {
-    #[inline]
-    fn deref_mut(&mut self) -> &mut T {
-        LazyLock::force_mut(self)
-    }
-}
-
 #[stable(feature = "lazy_cell", since = "1.80.0")]
 impl<T: Default> Default for LazyLock<T> {
     /// Creates a new lazy value using `Default` as the initializing function.