Skip to content

Commit 842c28c

Browse files
library: Stabilize const_ptr_write
Const-stabilizes: - `write` - `write_bytes` - `write_unaligned` In the following paths: - `core::ptr` - `core::ptr::NonNull` - pointer `<*mut T>` Const-stabilizes the internal `core::intrinsics`: - `write_bytes` - `write_via_move`
1 parent 18f09ed commit 842c28c

File tree

9 files changed

+12
-16
lines changed

9 files changed

+12
-16
lines changed

library/alloc/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@
172172
#![feature(allow_internal_unstable)]
173173
#![feature(cfg_sanitize)]
174174
#![feature(const_precise_live_drops)]
175-
#![feature(const_ptr_write)]
176175
#![feature(const_try)]
177176
#![feature(decl_macro)]
178177
#![feature(dropck_eyepatch)]

library/alloc/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#![feature(const_heap)]
99
#![cfg_attr(bootstrap, feature(const_mut_refs))]
1010
#![feature(const_slice_from_raw_parts_mut)]
11-
#![feature(const_ptr_write)]
1211
#![feature(const_try)]
1312
#![feature(core_intrinsics)]
1413
#![feature(extract_if)]

library/core/src/intrinsics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2636,7 +2636,7 @@ extern "rust-intrinsic" {
26362636
/// This intrinsic can *only* be called where the pointer is a local without
26372637
/// projections (`write_via_move(ptr, x)`, not `write_via_move(*ptr, x)`) so
26382638
/// that it trivially obeys runtime-MIR rules about derefs in operands.
2639-
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
2639+
#[rustc_const_stable(feature = "const_ptr_write", since = "CURRENT_RUSTC_VERSION")]
26402640
#[rustc_nounwind]
26412641
pub fn write_via_move<T>(ptr: *mut T, value: T);
26422642

@@ -3468,13 +3468,13 @@ pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
34683468
#[doc(alias = "memset")]
34693469
#[stable(feature = "rust1", since = "1.0.0")]
34703470
#[rustc_allowed_through_unstable_modules]
3471-
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
3471+
#[rustc_const_stable(feature = "const_ptr_write", since = "CURRENT_RUSTC_VERSION")]
34723472
#[inline(always)]
34733473
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
34743474
#[rustc_diagnostic_item = "ptr_write_bytes"]
34753475
pub const unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
34763476
extern "rust-intrinsic" {
3477-
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
3477+
#[rustc_const_stable(feature = "const_ptr_write", since = "CURRENT_RUSTC_VERSION")]
34783478
#[rustc_nounwind]
34793479
fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
34803480
}

library/core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@
142142
#![feature(const_ptr_as_ref)]
143143
#![feature(const_ptr_is_null)]
144144
#![feature(const_ptr_sub_ptr)]
145-
#![feature(const_ptr_write)]
146145
#![feature(const_raw_ptr_comparison)]
147146
#![feature(const_replace)]
148147
#![feature(const_size_of_val)]

library/core/src/ptr/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ pub const unsafe fn read_unaligned<T>(src: *const T) -> T {
16141614
/// ```
16151615
#[inline]
16161616
#[stable(feature = "rust1", since = "1.0.0")]
1617-
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
1617+
#[rustc_const_stable(feature = "const_ptr_write", since = "CURRENT_RUSTC_VERSION")]
16181618
#[rustc_diagnostic_item = "ptr_write"]
16191619
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
16201620
pub const unsafe fn write<T>(dst: *mut T, src: T) {
@@ -1722,7 +1722,8 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) {
17221722
/// ```
17231723
#[inline]
17241724
#[stable(feature = "ptr_unaligned", since = "1.17.0")]
1725-
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
1725+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_refs_to_cell))]
1726+
#[rustc_const_stable(feature = "const_ptr_write", since = "CURRENT_RUSTC_VERSION")]
17261727
#[rustc_diagnostic_item = "ptr_write_unaligned"]
17271728
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
17281729
pub const unsafe fn write_unaligned<T>(dst: *mut T, src: T) {

library/core/src/ptr/mut_ptr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ impl<T: ?Sized> *mut T {
13601360
///
13611361
/// [`ptr::write`]: crate::ptr::write()
13621362
#[stable(feature = "pointer_methods", since = "1.26.0")]
1363-
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
1363+
#[rustc_const_stable(feature = "const_ptr_write", since = "CURRENT_RUSTC_VERSION")]
13641364
#[inline(always)]
13651365
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
13661366
pub const unsafe fn write(self, val: T)
@@ -1379,7 +1379,7 @@ impl<T: ?Sized> *mut T {
13791379
/// [`ptr::write_bytes`]: crate::ptr::write_bytes()
13801380
#[doc(alias = "memset")]
13811381
#[stable(feature = "pointer_methods", since = "1.26.0")]
1382-
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
1382+
#[rustc_const_stable(feature = "const_ptr_write", since = "CURRENT_RUSTC_VERSION")]
13831383
#[inline(always)]
13841384
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
13851385
pub const unsafe fn write_bytes(self, val: u8, count: usize)
@@ -1420,7 +1420,7 @@ impl<T: ?Sized> *mut T {
14201420
///
14211421
/// [`ptr::write_unaligned`]: crate::ptr::write_unaligned()
14221422
#[stable(feature = "pointer_methods", since = "1.26.0")]
1423-
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
1423+
#[rustc_const_stable(feature = "const_ptr_write", since = "CURRENT_RUSTC_VERSION")]
14241424
#[inline(always)]
14251425
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
14261426
pub const unsafe fn write_unaligned(self, val: T)

library/core/src/ptr/non_null.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ impl<T: ?Sized> NonNull<T> {
10141014
#[inline(always)]
10151015
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
10161016
#[stable(feature = "non_null_convenience", since = "1.80.0")]
1017-
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
1017+
#[rustc_const_stable(feature = "const_ptr_write", since = "CURRENT_RUSTC_VERSION")]
10181018
pub const unsafe fn write(self, val: T)
10191019
where
10201020
T: Sized,
@@ -1033,7 +1033,7 @@ impl<T: ?Sized> NonNull<T> {
10331033
#[doc(alias = "memset")]
10341034
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
10351035
#[stable(feature = "non_null_convenience", since = "1.80.0")]
1036-
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
1036+
#[rustc_const_stable(feature = "const_ptr_write", since = "CURRENT_RUSTC_VERSION")]
10371037
pub const unsafe fn write_bytes(self, val: u8, count: usize)
10381038
where
10391039
T: Sized,
@@ -1074,7 +1074,7 @@ impl<T: ?Sized> NonNull<T> {
10741074
#[inline(always)]
10751075
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
10761076
#[stable(feature = "non_null_convenience", since = "1.80.0")]
1077-
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
1077+
#[rustc_const_stable(feature = "const_ptr_write", since = "CURRENT_RUSTC_VERSION")]
10781078
pub const unsafe fn write_unaligned(self, val: T)
10791079
where
10801080
T: Sized,

library/core/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#![feature(const_pin)]
3232
#![feature(const_pointer_is_aligned)]
3333
#![feature(const_ptr_as_ref)]
34-
#![feature(const_ptr_write)]
3534
#![feature(const_result)]
3635
#![feature(const_slice_from_ref)]
3736
#![feature(const_three_way_compare)]

tests/ui/consts/load-preserves-partial-init.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//@ run-pass
22

3-
#![feature(const_ptr_write)]
43
// issue: https://github.com/rust-lang/rust/issues/69488
54
// Loads of partially-initialized data could produce completely-uninitialized results.
65
// Test to make sure that we no longer do such a "deinitializing" load.

0 commit comments

Comments
 (0)