Skip to content

Commit 3b820ee

Browse files
library: Stabilize const_replace
Depends on stabilizing `const_ptr_write`. Const-stabilizes: - `core::mem::replace` - `core::ptr::replace`
1 parent ee21064 commit 3b820ee

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@
138138
#![feature(const_ptr_is_null)]
139139
#![feature(const_ptr_sub_ptr)]
140140
#![feature(const_raw_ptr_comparison)]
141-
#![feature(const_replace)]
142141
#![feature(const_size_of_val)]
143142
#![feature(const_size_of_val_raw)]
144143
#![feature(const_strict_overflow_ops)]

core/src/mem/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,8 @@ pub fn take<T: Default>(dest: &mut T) -> T {
857857
#[inline]
858858
#[stable(feature = "rust1", since = "1.0.0")]
859859
#[must_use = "if you don't need the old value, you can just assign the new value directly"]
860-
#[rustc_const_unstable(feature = "const_replace", issue = "83164")]
860+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
861+
#[rustc_const_stable(feature = "const_replace", since = "CURRENT_RUSTC_VERSION")]
861862
#[cfg_attr(not(test), rustc_diagnostic_item = "mem_replace")]
862863
pub const fn replace<T>(dest: &mut T, src: T) -> T {
863864
// It may be tempting to use `swap` to avoid `unsafe` here. Don't!

core/src/ptr/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,8 @@ const unsafe fn swap_nonoverlapping_simple_untyped<T>(x: *mut T, y: *mut T, coun
12631263
/// ```
12641264
#[inline]
12651265
#[stable(feature = "rust1", since = "1.0.0")]
1266-
#[rustc_const_unstable(feature = "const_replace", issue = "83164")]
1266+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
1267+
#[rustc_const_stable(feature = "const_replace", since = "CURRENT_RUSTC_VERSION")]
12671268
#[rustc_diagnostic_item = "ptr_replace"]
12681269
pub const unsafe fn replace<T>(dst: *mut T, src: T) -> T {
12691270
// SAFETY: the caller must guarantee that `dst` is valid to be

0 commit comments

Comments
 (0)