Skip to content

Commit 001ea32

Browse files
committed
Stabilize [const_]pointer_byte_offsets
1 parent b11bf65 commit 001ea32

File tree

10 files changed

+98
-93
lines changed

10 files changed

+98
-93
lines changed

compiler/rustc_arena/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![feature(maybe_uninit_slice)]
1717
#![feature(min_specialization)]
1818
#![feature(decl_macro)]
19-
#![feature(pointer_byte_offsets)]
2019
#![feature(rustc_attrs)]
2120
#![cfg_attr(test, feature(test))]
2221
#![feature(strict_provenance)]

library/alloc/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@
128128
#![cfg_attr(test, feature(new_uninit))]
129129
#![feature(nonnull_slice_from_raw_parts)]
130130
#![feature(pattern)]
131-
#![feature(pointer_byte_offsets)]
132131
#![cfg_attr(not(bootstrap), feature(provide_any))]
133132
#![feature(ptr_internals)]
134133
#![feature(ptr_metadata)]

library/core/src/ptr/const_ptr.rs

+21-14
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,9 @@ impl<T: ?Sized> *const T {
470470
/// leaving the metadata untouched.
471471
#[must_use]
472472
#[inline(always)]
473-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
474-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
473+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
474+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
475+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
475476
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
476477
pub const unsafe fn byte_offset(self, count: isize) -> Self {
477478
// SAFETY: the caller must uphold the safety contract for `offset`.
@@ -553,8 +554,9 @@ impl<T: ?Sized> *const T {
553554
/// leaving the metadata untouched.
554555
#[must_use]
555556
#[inline(always)]
556-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
557-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
557+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
558+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
559+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
558560
pub const fn wrapping_byte_offset(self, count: isize) -> Self {
559561
from_raw_parts::<T>(self.cast::<u8>().wrapping_offset(count).cast::<()>(), metadata(self))
560562
}
@@ -679,8 +681,9 @@ impl<T: ?Sized> *const T {
679681
/// For non-`Sized` pointees this operation considers only the data pointers,
680682
/// ignoring the metadata.
681683
#[inline(always)]
682-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
683-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
684+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
685+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
686+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
684687
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
685688
pub const unsafe fn byte_offset_from(self, origin: *const T) -> isize {
686689
// SAFETY: the caller must uphold the safety contract for `offset_from`.
@@ -903,8 +906,9 @@ impl<T: ?Sized> *const T {
903906
/// leaving the metadata untouched.
904907
#[must_use]
905908
#[inline(always)]
906-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
907-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
909+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
910+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
911+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
908912
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
909913
pub const unsafe fn byte_add(self, count: usize) -> Self {
910914
// SAFETY: the caller must uphold the safety contract for `add`.
@@ -990,8 +994,9 @@ impl<T: ?Sized> *const T {
990994
/// leaving the metadata untouched.
991995
#[must_use]
992996
#[inline(always)]
993-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
994-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
997+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
998+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
999+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
9951000
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
9961001
pub const unsafe fn byte_sub(self, count: usize) -> Self {
9971002
// SAFETY: the caller must uphold the safety contract for `sub`.
@@ -1073,8 +1078,9 @@ impl<T: ?Sized> *const T {
10731078
/// leaving the metadata untouched.
10741079
#[must_use]
10751080
#[inline(always)]
1076-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
1077-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
1081+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1082+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1083+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
10781084
pub const fn wrapping_byte_add(self, count: usize) -> Self {
10791085
from_raw_parts::<T>(self.cast::<u8>().wrapping_add(count).cast::<()>(), metadata(self))
10801086
}
@@ -1153,8 +1159,9 @@ impl<T: ?Sized> *const T {
11531159
/// leaving the metadata untouched.
11541160
#[must_use]
11551161
#[inline(always)]
1156-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
1157-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
1162+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1163+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1164+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
11581165
pub const fn wrapping_byte_sub(self, count: usize) -> Self {
11591166
from_raw_parts::<T>(self.cast::<u8>().wrapping_sub(count).cast::<()>(), metadata(self))
11601167
}

library/core/src/ptr/mut_ptr.rs

+21-14
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,9 @@ impl<T: ?Sized> *mut T {
484484
/// leaving the metadata untouched.
485485
#[must_use]
486486
#[inline(always)]
487-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
488-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
487+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
488+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
489+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
489490
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
490491
pub const unsafe fn byte_offset(self, count: isize) -> Self {
491492
// SAFETY: the caller must uphold the safety contract for `offset`.
@@ -566,8 +567,9 @@ impl<T: ?Sized> *mut T {
566567
/// leaving the metadata untouched.
567568
#[must_use]
568569
#[inline(always)]
569-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
570-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
570+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
571+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
572+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
571573
pub const fn wrapping_byte_offset(self, count: isize) -> Self {
572574
from_raw_parts_mut::<T>(
573575
self.cast::<u8>().wrapping_offset(count).cast::<()>(),
@@ -860,8 +862,9 @@ impl<T: ?Sized> *mut T {
860862
/// For non-`Sized` pointees this operation considers only the data pointers,
861863
/// ignoring the metadata.
862864
#[inline(always)]
863-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
864-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
865+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
866+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
867+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
865868
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
866869
pub const unsafe fn byte_offset_from(self, origin: *const T) -> isize {
867870
// SAFETY: the caller must uphold the safety contract for `offset_from`.
@@ -1017,8 +1020,9 @@ impl<T: ?Sized> *mut T {
10171020
/// leaving the metadata untouched.
10181021
#[must_use]
10191022
#[inline(always)]
1020-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
1021-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
1023+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1024+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1025+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
10221026
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
10231027
pub const unsafe fn byte_add(self, count: usize) -> Self {
10241028
// SAFETY: the caller must uphold the safety contract for `add`.
@@ -1104,8 +1108,9 @@ impl<T: ?Sized> *mut T {
11041108
/// leaving the metadata untouched.
11051109
#[must_use]
11061110
#[inline(always)]
1107-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
1108-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
1111+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1112+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1113+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
11091114
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
11101115
pub const unsafe fn byte_sub(self, count: usize) -> Self {
11111116
// SAFETY: the caller must uphold the safety contract for `sub`.
@@ -1187,8 +1192,9 @@ impl<T: ?Sized> *mut T {
11871192
/// leaving the metadata untouched.
11881193
#[must_use]
11891194
#[inline(always)]
1190-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
1191-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
1195+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1196+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1197+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
11921198
pub const fn wrapping_byte_add(self, count: usize) -> Self {
11931199
from_raw_parts_mut::<T>(self.cast::<u8>().wrapping_add(count).cast::<()>(), metadata(self))
11941200
}
@@ -1267,8 +1273,9 @@ impl<T: ?Sized> *mut T {
12671273
/// leaving the metadata untouched.
12681274
#[must_use]
12691275
#[inline(always)]
1270-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
1271-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
1276+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1277+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1278+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
12721279
pub const fn wrapping_byte_sub(self, count: usize) -> Self {
12731280
from_raw_parts_mut::<T>(self.cast::<u8>().wrapping_sub(count).cast::<()>(), metadata(self))
12741281
}

library/core/tests/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#![feature(const_maybe_uninit_assume_init_read)]
1515
#![feature(const_nonnull_new)]
1616
#![feature(const_num_from_num)]
17-
#![feature(const_pointer_byte_offsets)]
1817
#![feature(const_ptr_as_ref)]
1918
#![feature(const_ptr_read)]
2019
#![feature(const_ptr_write)]
@@ -75,7 +74,6 @@
7574
#![feature(const_pin)]
7675
#![feature(never_type)]
7776
#![feature(unwrap_infallible)]
78-
#![feature(pointer_byte_offsets)]
7977
#![feature(portable_simd)]
8078
#![feature(ptr_metadata)]
8179
#![feature(once_cell)]

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@
301301
#![feature(panic_can_unwind)]
302302
#![feature(panic_info_message)]
303303
#![feature(panic_internals)]
304-
#![feature(pointer_byte_offsets)]
305304
#![feature(pointer_is_aligned)]
306305
#![feature(portable_simd)]
307306
#![feature(prelude_2024)]

src/test/ui/const-ptr/allowed_slices.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#![feature(
33
slice_from_ptr_range,
44
const_slice_from_ptr_range,
5-
pointer_byte_offsets,
6-
const_pointer_byte_offsets
75
)]
86
use std::{
97
mem::MaybeUninit,

0 commit comments

Comments
 (0)