Skip to content

Commit 24a21e3

Browse files
library: Stabilize const_replace
Depends on stabilizing `const_ptr_write`. Const-stabilizes: - `core::mem::replace` - `core::ptr::replace`
1 parent 842c28c commit 24a21e3

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@
143143
#![feature(const_ptr_is_null)]
144144
#![feature(const_ptr_sub_ptr)]
145145
#![feature(const_raw_ptr_comparison)]
146-
#![feature(const_replace)]
147146
#![feature(const_size_of_val)]
148147
#![feature(const_size_of_val_raw)]
149148
#![feature(const_slice_from_raw_parts_mut)]

library/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!

library/core/src/ptr/mod.rs

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

0 commit comments

Comments
 (0)