about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-11-05 23:43:55 +0100
committerGitHub <noreply@github.com>2024-11-05 23:43:55 +0100
commitefa5af96a1ab626047feb70f54b1cfce0d4a2d36 (patch)
treed361c593574af08800df7c92d9177b99011ddf92
parentbc5cf994db9fb46712cefd89f78ad7fc51f184a2 (diff)
parent6828a1edc63819120c7d11544f149cdd839ef915 (diff)
downloadrust-efa5af96a1ab626047feb70f54b1cfce0d4a2d36.tar.gz
rust-efa5af96a1ab626047feb70f54b1cfce0d4a2d36.zip
Rollup merge of #131261 - clarfonthey:unsafe-cell-from-mut, r=m-ou-se
Stabilize `UnsafeCell::from_mut`

Closes #111645.
FCP: https://github.com/rust-lang/rust/issues/111645#issuecomment-2393893003

Note that because `const_mut_refs` and `const_refs_to_cell` was stabilized, it's okay to const-stabilize this method as well.
-rw-r--r--library/core/src/cell.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs
index 7e6c042274d..ab76cd7a6be 100644
--- a/library/core/src/cell.rs
+++ b/library/core/src/cell.rs
@@ -2122,7 +2122,6 @@ impl<T: ?Sized> UnsafeCell<T> {
     /// # Examples
     ///
     /// ```
-    /// # #![feature(unsafe_cell_from_mut)]
     /// use std::cell::UnsafeCell;
     ///
     /// let mut val = 42;
@@ -2132,7 +2131,9 @@ impl<T: ?Sized> UnsafeCell<T> {
     /// assert_eq!(*uc.get_mut(), 41);
     /// ```
     #[inline(always)]
-    #[unstable(feature = "unsafe_cell_from_mut", issue = "111645")]
+    #[stable(feature = "unsafe_cell_from_mut", since = "CURRENT_RUSTC_VERSION")]
+    #[rustc_const_stable(feature = "unsafe_cell_from_mut", since = "CURRENT_RUSTC_VERSION")]
+    #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
     pub const fn from_mut(value: &mut T) -> &mut UnsafeCell<T> {
         // SAFETY: `UnsafeCell<T>` has the same memory layout as `T` due to #[repr(transparent)].
         unsafe { &mut *(value as *mut T as *mut UnsafeCell<T>) }