Skip to content

Commit 1a9c521

Browse files
Destabilize Lazy{Cell,Lock}::{force,deref}_mut
1 parent d0a2ca4 commit 1a9c521

File tree

2 files changed

+4
-28
lines changed

2 files changed

+4
-28
lines changed

library/core/src/cell/lazy.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::UnsafeCell;
22
use crate::hint::unreachable_unchecked;
3-
use crate::ops::{Deref, DerefMut};
3+
use crate::ops::Deref;
44
use crate::{fmt, mem};
55

66
enum State<T, F> {
@@ -122,8 +122,6 @@ impl<T, F: FnOnce() -> T> LazyCell<T, F> {
122122
/// Forces the evaluation of this lazy value and returns a mutable reference to
123123
/// the result.
124124
///
125-
/// This is equivalent to the `DerefMut` impl, but is explicit.
126-
///
127125
/// # Examples
128126
///
129127
/// ```
@@ -135,11 +133,9 @@ impl<T, F: FnOnce() -> T> LazyCell<T, F> {
135133
/// assert_eq!(*p, 92);
136134
/// *p = 44;
137135
/// assert_eq!(*lazy, 44);
138-
/// *lazy = 55; // Using `DerefMut`
139-
/// assert_eq!(*lazy, 55);
140136
/// ```
141137
#[inline]
142-
#[stable(feature = "lazy_deref_mut", since = "CURRENT_RUSTC_VERSION")]
138+
#[unstable(feature = "lazy_get", issue = "129333")]
143139
pub fn force_mut(this: &mut LazyCell<T, F>) -> &mut T {
144140
#[cold]
145141
/// # Safety
@@ -286,14 +282,6 @@ impl<T, F: FnOnce() -> T> Deref for LazyCell<T, F> {
286282
}
287283
}
288284

289-
#[stable(feature = "lazy_deref_mut", since = "CURRENT_RUSTC_VERSION")]
290-
impl<T, F: FnOnce() -> T> DerefMut for LazyCell<T, F> {
291-
#[inline]
292-
fn deref_mut(&mut self) -> &mut T {
293-
LazyCell::force_mut(self)
294-
}
295-
}
296-
297285
#[stable(feature = "lazy_cell", since = "1.80.0")]
298286
impl<T: Default> Default for LazyCell<T> {
299287
/// Creates a new lazy value using `Default` as the initializing function.

library/std/src/sync/lazy_lock.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::once::ExclusiveState;
22
use crate::cell::UnsafeCell;
33
use crate::mem::ManuallyDrop;
4-
use crate::ops::{Deref, DerefMut};
4+
use crate::ops::Deref;
55
use crate::panic::{RefUnwindSafe, UnwindSafe};
66
use crate::sync::Once;
77
use crate::{fmt, ptr};
@@ -137,8 +137,6 @@ impl<T, F: FnOnce() -> T> LazyLock<T, F> {
137137
/// Forces the evaluation of this lazy value and returns a mutable reference to
138138
/// the result.
139139
///
140-
/// This is equivalent to the `DerefMut` impl, but is explicit.
141-
///
142140
/// # Examples
143141
///
144142
/// ```
@@ -150,11 +148,9 @@ impl<T, F: FnOnce() -> T> LazyLock<T, F> {
150148
/// assert_eq!(*p, 92);
151149
/// *p = 44;
152150
/// assert_eq!(*lazy, 44);
153-
/// *lazy = 55; // Using `DerefMut`
154-
/// assert_eq!(*lazy, 55);
155151
/// ```
156152
#[inline]
157-
#[stable(feature = "lazy_deref_mut", since = "CURRENT_RUSTC_VERSION")]
153+
#[unstable(feature = "lazy_get", issue = "129334")]
158154
pub fn force_mut(this: &mut LazyLock<T, F>) -> &mut T {
159155
#[cold]
160156
/// # Safety
@@ -317,14 +313,6 @@ impl<T, F: FnOnce() -> T> Deref for LazyLock<T, F> {
317313
}
318314
}
319315

320-
#[stable(feature = "lazy_deref_mut", since = "CURRENT_RUSTC_VERSION")]
321-
impl<T, F: FnOnce() -> T> DerefMut for LazyLock<T, F> {
322-
#[inline]
323-
fn deref_mut(&mut self) -> &mut T {
324-
LazyLock::force_mut(self)
325-
}
326-
}
327-
328316
#[stable(feature = "lazy_cell", since = "1.80.0")]
329317
impl<T: Default> Default for LazyLock<T> {
330318
/// Creates a new lazy value using `Default` as the initializing function.

0 commit comments

Comments
 (0)