Skip to content

stabilize const_cell #137928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ impl<T> Cell<T> {
/// ```
#[inline]
#[stable(feature = "move_cell", since = "1.17.0")]
#[rustc_const_unstable(feature = "const_cell", issue = "131283")]
#[rustc_const_stable(feature = "const_cell", since = "CURRENT_RUSTC_VERSION")]
#[rustc_confusables("swap")]
pub const fn replace(&self, val: T) -> T {
// SAFETY: This can cause data races if called from a separate thread,
Expand Down Expand Up @@ -537,7 +537,7 @@ impl<T: Copy> Cell<T> {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cell", issue = "131283")]
#[rustc_const_stable(feature = "const_cell", since = "CURRENT_RUSTC_VERSION")]
pub const fn get(&self) -> T {
// SAFETY: This can cause data races if called from a separate thread,
// but `Cell` is `!Sync` so this won't happen.
Expand Down Expand Up @@ -617,7 +617,7 @@ impl<T: ?Sized> Cell<T> {
/// ```
#[inline]
#[stable(feature = "cell_get_mut", since = "1.11.0")]
#[rustc_const_unstable(feature = "const_cell", issue = "131283")]
#[rustc_const_stable(feature = "const_cell", since = "CURRENT_RUSTC_VERSION")]
pub const fn get_mut(&mut self) -> &mut T {
self.value.get_mut()
}
Expand All @@ -637,7 +637,7 @@ impl<T: ?Sized> Cell<T> {
/// ```
#[inline]
#[stable(feature = "as_cell", since = "1.37.0")]
#[rustc_const_unstable(feature = "const_cell", issue = "131283")]
#[rustc_const_stable(feature = "const_cell", since = "CURRENT_RUSTC_VERSION")]
pub const fn from_mut(t: &mut T) -> &Cell<T> {
// SAFETY: `&mut` ensures unique access.
unsafe { &*(t as *mut T as *const Cell<T>) }
Expand Down Expand Up @@ -695,7 +695,7 @@ impl<T> Cell<[T]> {
/// assert_eq!(slice_cell.len(), 3);
/// ```
#[stable(feature = "as_cell", since = "1.37.0")]
#[rustc_const_unstable(feature = "const_cell", issue = "131283")]
#[rustc_const_stable(feature = "const_cell", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_slice_of_cells(&self) -> &[Cell<T>] {
// SAFETY: `Cell<T>` has the same memory layout as `T`.
unsafe { &*(self as *const Cell<[T]> as *const [Cell<T>]) }
Expand Down
Loading