From c187c98f700c4b55f4a584f6c59b36a3b9a652e4 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 22 Aug 2024 08:19:26 +0200 Subject: [PATCH] crater experiment: de-const-stabilize UnsafeCell::get --- library/core/src/cell.rs | 6 +++--- library/core/src/lib.rs | 1 + library/core/src/sync/atomic.rs | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index d860f3415d982..c4520fc05cc54 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -581,7 +581,7 @@ impl Cell { /// ``` #[inline] #[stable(feature = "cell_as_ptr", since = "1.12.0")] - #[rustc_const_stable(feature = "const_cell_as_ptr", since = "1.32.0")] + #[rustc_const_unstable(feature = "const_unsafecell_get", issue = "1")] #[rustc_never_returns_null_ptr] pub const fn as_ptr(&self) -> *mut T { self.value.get() @@ -2142,7 +2142,7 @@ impl UnsafeCell { /// ``` #[inline(always)] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_unsafecell_get", since = "1.32.0")] + #[rustc_const_unstable(feature = "const_unsafecell_get", issue = "1")] #[rustc_never_returns_null_ptr] pub const fn get(&self) -> *mut T { // We can just cast the pointer from `UnsafeCell` to `T` because of @@ -2203,7 +2203,7 @@ impl UnsafeCell { /// ``` #[inline(always)] #[stable(feature = "unsafe_cell_raw_get", since = "1.56.0")] - #[rustc_const_stable(feature = "unsafe_cell_raw_get", since = "1.56.0")] + #[rustc_const_unstable(feature = "const_unsafecell_get", issue = "1")] #[rustc_diagnostic_item = "unsafe_cell_raw_get"] pub const fn raw_get(this: *const Self) -> *mut T { // We can just cast the pointer from `UnsafeCell` to `T` because of diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index e3640627c562a..afcf91e7db320 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -163,6 +163,7 @@ #![feature(const_typed_swap)] #![feature(const_ub_checks)] #![feature(const_unicode_case_lookup)] +#![feature(const_unsafecell_get)] #![feature(const_unsafecell_get_mut)] #![feature(coverage_attribute)] #![feature(do_not_recommend)] diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 495d9191a9f85..bfd91599132c4 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -1114,7 +1114,7 @@ impl AtomicBool { /// ``` #[inline] #[stable(feature = "atomic_as_ptr", since = "1.70.0")] - #[rustc_const_stable(feature = "atomic_as_ptr", since = "1.70.0")] + #[rustc_const_unstable(feature = "const_unsafecell_get", issue = "1")] #[rustc_never_returns_null_ptr] pub const fn as_ptr(&self) -> *mut bool { self.v.get().cast() @@ -2051,7 +2051,7 @@ impl AtomicPtr { /// ``` #[inline] #[stable(feature = "atomic_as_ptr", since = "1.70.0")] - #[rustc_const_stable(feature = "atomic_as_ptr", since = "1.70.0")] + #[rustc_const_unstable(feature = "const_unsafecell_get", issue = "1")] #[rustc_never_returns_null_ptr] pub const fn as_ptr(&self) -> *mut *mut T { self.p.get() @@ -3015,7 +3015,7 @@ macro_rules! atomic_int { /// ``` #[inline] #[stable(feature = "atomic_as_ptr", since = "1.70.0")] - #[rustc_const_stable(feature = "atomic_as_ptr", since = "1.70.0")] + #[rustc_const_unstable(feature = "const_unsafecell_get", issue = "1")] #[rustc_never_returns_null_ptr] pub const fn as_ptr(&self) -> *mut $int_type { self.v.get()