Skip to content

Commit 81c2459

Browse files
borsusbalbin
authored andcommitted
Stabilize const_ptr_read
1 parent 4a18324 commit 81c2459

File tree

17 files changed

+35
-42
lines changed

17 files changed

+35
-42
lines changed

library/alloc/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@
113113
#![feature(const_maybe_uninit_write)]
114114
#![feature(const_maybe_uninit_zeroed)]
115115
#![feature(const_pin)]
116-
#![feature(const_ptr_read)]
117116
#![feature(const_refs_to_cell)]
118117
#![feature(const_size_of_val)]
119118
#![feature(const_waker)]

library/core/src/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2260,7 +2260,7 @@ extern "rust-intrinsic" {
22602260
/// This intrinsic can *only* be called where the pointer is a local without
22612261
/// projections (`read_via_copy(ptr)`, not `read_via_copy(*ptr)`) so that it
22622262
/// trivially obeys runtime-MIR rules about derefs in operands.
2263-
#[rustc_const_unstable(feature = "const_ptr_read", issue = "80377")]
2263+
#[rustc_const_stable(feature = "const_ptr_read", since = "CURRENT_RUSTC_VERSION")]
22642264
#[rustc_nounwind]
22652265
pub fn read_via_copy<T>(ptr: *const T) -> T;
22662266

library/core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@
140140
#![feature(const_pointer_is_aligned)]
141141
#![feature(const_ptr_as_ref)]
142142
#![feature(const_ptr_is_null)]
143-
#![feature(const_ptr_read)]
144143
#![feature(const_ptr_sub_ptr)]
145144
#![feature(const_ptr_write)]
146145
#![feature(const_raw_ptr_comparison)]

library/core/src/ptr/const_ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ impl<T: ?Sized> *const T {
11951195
///
11961196
/// [`ptr::read`]: crate::ptr::read()
11971197
#[stable(feature = "pointer_methods", since = "1.26.0")]
1198-
#[rustc_const_unstable(feature = "const_ptr_read", issue = "80377")]
1198+
#[rustc_const_stable(feature = "const_ptr_read", since = "CURRENT_RUSTC_VERSION")]
11991199
#[inline]
12001200
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
12011201
pub const unsafe fn read(self) -> T
@@ -1236,7 +1236,7 @@ impl<T: ?Sized> *const T {
12361236
///
12371237
/// [`ptr::read_unaligned`]: crate::ptr::read_unaligned()
12381238
#[stable(feature = "pointer_methods", since = "1.26.0")]
1239-
#[rustc_const_unstable(feature = "const_ptr_read", issue = "80377")]
1239+
#[rustc_const_stable(feature = "const_ptr_read", since = "CURRENT_RUSTC_VERSION")]
12401240
#[inline]
12411241
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
12421242
pub const unsafe fn read_unaligned(self) -> T

library/core/src/ptr/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,8 @@ pub const unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
11331133
/// [valid]: self#safety
11341134
#[inline]
11351135
#[stable(feature = "rust1", since = "1.0.0")]
1136-
#[rustc_const_unstable(feature = "const_ptr_read", issue = "80377")]
1136+
#[rustc_const_stable(feature = "const_ptr_read", since = "CURRENT_RUSTC_VERSION")]
1137+
#[rustc_allow_const_fn_unstable(const_mut_refs, const_maybe_uninit_as_mut_ptr)]
11371138
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
11381139
pub const unsafe fn read<T>(src: *const T) -> T {
11391140
// It would be semantically correct to implement this via `copy_nonoverlapping`
@@ -1249,7 +1250,8 @@ pub const unsafe fn read<T>(src: *const T) -> T {
12491250
/// ```
12501251
#[inline]
12511252
#[stable(feature = "ptr_unaligned", since = "1.17.0")]
1252-
#[rustc_const_unstable(feature = "const_ptr_read", issue = "80377")]
1253+
#[rustc_const_stable(feature = "const_ptr_read", since = "CURRENT_RUSTC_VERSION")]
1254+
#[rustc_allow_const_fn_unstable(const_mut_refs, const_maybe_uninit_as_mut_ptr)]
12531255
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
12541256
pub const unsafe fn read_unaligned<T>(src: *const T) -> T {
12551257
let mut tmp = MaybeUninit::<T>::uninit();

library/core/src/ptr/mut_ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ impl<T: ?Sized> *mut T {
13051305
///
13061306
/// [`ptr::read`]: crate::ptr::read()
13071307
#[stable(feature = "pointer_methods", since = "1.26.0")]
1308-
#[rustc_const_unstable(feature = "const_ptr_read", issue = "80377")]
1308+
#[rustc_const_stable(feature = "const_ptr_read", since = "CURRENT_RUSTC_VERSION")]
13091309
#[inline(always)]
13101310
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
13111311
pub const unsafe fn read(self) -> T
@@ -1346,7 +1346,7 @@ impl<T: ?Sized> *mut T {
13461346
///
13471347
/// [`ptr::read_unaligned`]: crate::ptr::read_unaligned()
13481348
#[stable(feature = "pointer_methods", since = "1.26.0")]
1349-
#[rustc_const_unstable(feature = "const_ptr_read", issue = "80377")]
1349+
#[rustc_const_stable(feature = "const_ptr_read", since = "CURRENT_RUSTC_VERSION")]
13501350
#[inline(always)]
13511351
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
13521352
pub const unsafe fn read_unaligned(self) -> T

library/core/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#![feature(const_pointer_byte_offsets)]
1919
#![feature(const_pointer_is_aligned)]
2020
#![feature(const_ptr_as_ref)]
21-
#![feature(const_ptr_read)]
2221
#![feature(const_ptr_write)]
2322
#![feature(const_trait_impl)]
2423
#![feature(const_likely)]

src/tools/miri/tests/fail/const-ub-checks.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(const_ptr_read)]
21

32
const UNALIGNED_READ: () = unsafe {
43
let x = &[0u8; 4];

tests/ui/const-generics/issues/issue-105821.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// check-pass
22

33
#![allow(incomplete_features)]
4-
#![feature(adt_const_params, const_ptr_read, generic_const_exprs)]
4+
#![feature(adt_const_params, generic_const_exprs)]
55
#![allow(dead_code)]
66

77
const fn catone<const M: usize>(_a: &[u8; M]) -> [u8; M + 1]

tests/ui/const-ptr/out_of_bounds_read.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// error-pattern: evaluation of constant value failed
22

3-
#![feature(const_ptr_read)]
4-
53
fn main() {
64
use std::ptr;
75

0 commit comments

Comments
 (0)