Skip to content

Commit 2331520

Browse files
committed
Auto merge of #129399 - RalfJung:no-const-refs-to-cell, r=<try>
crater experiment: de-const-stabilize UnsafeCell::get and various as_ptr methods These should not have been stabilized before const_refs_to_cell. For now I mostly want to see whether any code out there actually uses these methods, since it shouldn't be possible to do anything useful with them... Cc `@rust-lang/wg-const-eval`
2 parents a32d4a0 + c187c98 commit 2331520

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

library/core/src/cell.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ impl<T: ?Sized> Cell<T> {
581581
/// ```
582582
#[inline]
583583
#[stable(feature = "cell_as_ptr", since = "1.12.0")]
584-
#[rustc_const_stable(feature = "const_cell_as_ptr", since = "1.32.0")]
584+
#[rustc_const_unstable(feature = "const_unsafecell_get", issue = "1")]
585585
#[rustc_never_returns_null_ptr]
586586
pub const fn as_ptr(&self) -> *mut T {
587587
self.value.get()
@@ -2142,7 +2142,7 @@ impl<T: ?Sized> UnsafeCell<T> {
21422142
/// ```
21432143
#[inline(always)]
21442144
#[stable(feature = "rust1", since = "1.0.0")]
2145-
#[rustc_const_stable(feature = "const_unsafecell_get", since = "1.32.0")]
2145+
#[rustc_const_unstable(feature = "const_unsafecell_get", issue = "1")]
21462146
#[rustc_never_returns_null_ptr]
21472147
pub const fn get(&self) -> *mut T {
21482148
// We can just cast the pointer from `UnsafeCell<T>` to `T` because of
@@ -2203,7 +2203,7 @@ impl<T: ?Sized> UnsafeCell<T> {
22032203
/// ```
22042204
#[inline(always)]
22052205
#[stable(feature = "unsafe_cell_raw_get", since = "1.56.0")]
2206-
#[rustc_const_stable(feature = "unsafe_cell_raw_get", since = "1.56.0")]
2206+
#[rustc_const_unstable(feature = "const_unsafecell_get", issue = "1")]
22072207
#[rustc_diagnostic_item = "unsafe_cell_raw_get"]
22082208
pub const fn raw_get(this: *const Self) -> *mut T {
22092209
// We can just cast the pointer from `UnsafeCell<T>` to `T` because of

library/core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
#![feature(const_typed_swap)]
164164
#![feature(const_ub_checks)]
165165
#![feature(const_unicode_case_lookup)]
166+
#![feature(const_unsafecell_get)]
166167
#![feature(const_unsafecell_get_mut)]
167168
#![feature(coverage_attribute)]
168169
#![feature(do_not_recommend)]

library/core/src/sync/atomic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ impl AtomicBool {
11141114
/// ```
11151115
#[inline]
11161116
#[stable(feature = "atomic_as_ptr", since = "1.70.0")]
1117-
#[rustc_const_stable(feature = "atomic_as_ptr", since = "1.70.0")]
1117+
#[rustc_const_unstable(feature = "const_unsafecell_get", issue = "1")]
11181118
#[rustc_never_returns_null_ptr]
11191119
pub const fn as_ptr(&self) -> *mut bool {
11201120
self.v.get().cast()
@@ -2051,7 +2051,7 @@ impl<T> AtomicPtr<T> {
20512051
/// ```
20522052
#[inline]
20532053
#[stable(feature = "atomic_as_ptr", since = "1.70.0")]
2054-
#[rustc_const_stable(feature = "atomic_as_ptr", since = "1.70.0")]
2054+
#[rustc_const_unstable(feature = "const_unsafecell_get", issue = "1")]
20552055
#[rustc_never_returns_null_ptr]
20562056
pub const fn as_ptr(&self) -> *mut *mut T {
20572057
self.p.get()
@@ -3015,7 +3015,7 @@ macro_rules! atomic_int {
30153015
/// ```
30163016
#[inline]
30173017
#[stable(feature = "atomic_as_ptr", since = "1.70.0")]
3018-
#[rustc_const_stable(feature = "atomic_as_ptr", since = "1.70.0")]
3018+
#[rustc_const_unstable(feature = "const_unsafecell_get", issue = "1")]
30193019
#[rustc_never_returns_null_ptr]
30203020
pub const fn as_ptr(&self) -> *mut $int_type {
30213021
self.v.get()

0 commit comments

Comments
 (0)