Skip to content

Commit 54e57e6

Browse files
committed
Auto merge of #116205 - WaffleLapkin:stabilize_pointer_byte_offsets, r=dtolnay
Stabilize `[const_]pointer_byte_offsets` Closes #96283 Awaiting FCP completion: #96283 (comment) r? libs-api
2 parents 707d8c3 + fe97fdf commit 54e57e6

File tree

18 files changed

+69
-77
lines changed

18 files changed

+69
-77
lines changed

compiler/rustc_arena/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#![feature(new_uninit)]
1919
#![feature(maybe_uninit_slice)]
2020
#![feature(decl_macro)]
21-
#![feature(pointer_byte_offsets)]
2221
#![feature(rustc_attrs)]
2322
#![cfg_attr(test, feature(test))]
2423
#![feature(strict_provenance)]

library/alloc/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@
141141
#![feature(maybe_uninit_uninit_array)]
142142
#![feature(maybe_uninit_uninit_array_transpose)]
143143
#![feature(pattern)]
144-
#![feature(pointer_byte_offsets)]
145144
#![feature(ptr_addr_eq)]
146145
#![feature(ptr_internals)]
147146
#![feature(ptr_metadata)]

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@
148148
#![feature(const_option)]
149149
#![feature(const_option_ext)]
150150
#![feature(const_pin)]
151-
#![feature(const_pointer_byte_offsets)]
152151
#![feature(const_pointer_is_aligned)]
153152
#![feature(const_ptr_as_ref)]
154153
#![feature(const_ptr_is_null)]

library/core/src/ptr/const_ptr.rs

+21-16
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,9 @@ impl<T: ?Sized> *const T {
480480
/// leaving the metadata untouched.
481481
#[must_use]
482482
#[inline(always)]
483-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
484-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
483+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
484+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
485+
#[rustc_allow_const_fn_unstable(set_ptr_value)]
485486
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
486487
pub const unsafe fn byte_offset(self, count: isize) -> Self {
487488
// SAFETY: the caller must uphold the safety contract for `offset`.
@@ -560,8 +561,9 @@ impl<T: ?Sized> *const T {
560561
/// leaving the metadata untouched.
561562
#[must_use]
562563
#[inline(always)]
563-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
564-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
564+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
565+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
566+
#[rustc_allow_const_fn_unstable(set_ptr_value)]
565567
pub const fn wrapping_byte_offset(self, count: isize) -> Self {
566568
self.cast::<u8>().wrapping_offset(count).with_metadata_of(self)
567569
}
@@ -726,8 +728,9 @@ impl<T: ?Sized> *const T {
726728
/// For non-`Sized` pointees this operation considers only the data pointers,
727729
/// ignoring the metadata.
728730
#[inline(always)]
729-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
730-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
731+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
732+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
733+
#[rustc_allow_const_fn_unstable(set_ptr_value)]
731734
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
732735
pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize {
733736
// SAFETY: the caller must uphold the safety contract for `offset_from`.
@@ -952,8 +955,9 @@ impl<T: ?Sized> *const T {
952955
/// leaving the metadata untouched.
953956
#[must_use]
954957
#[inline(always)]
955-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
956-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
958+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
959+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
960+
#[rustc_allow_const_fn_unstable(set_ptr_value)]
957961
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
958962
pub const unsafe fn byte_add(self, count: usize) -> Self {
959963
// SAFETY: the caller must uphold the safety contract for `add`.
@@ -1045,8 +1049,9 @@ impl<T: ?Sized> *const T {
10451049
/// leaving the metadata untouched.
10461050
#[must_use]
10471051
#[inline(always)]
1048-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
1049-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
1052+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1053+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1054+
#[rustc_allow_const_fn_unstable(set_ptr_value)]
10501055
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
10511056
pub const unsafe fn byte_sub(self, count: usize) -> Self {
10521057
// SAFETY: the caller must uphold the safety contract for `sub`.
@@ -1125,8 +1130,9 @@ impl<T: ?Sized> *const T {
11251130
/// leaving the metadata untouched.
11261131
#[must_use]
11271132
#[inline(always)]
1128-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
1129-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
1133+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1134+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1135+
#[rustc_allow_const_fn_unstable(set_ptr_value)]
11301136
pub const fn wrapping_byte_add(self, count: usize) -> Self {
11311137
self.cast::<u8>().wrapping_add(count).with_metadata_of(self)
11321138
}
@@ -1203,8 +1209,9 @@ impl<T: ?Sized> *const T {
12031209
/// leaving the metadata untouched.
12041210
#[must_use]
12051211
#[inline(always)]
1206-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
1207-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
1212+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1213+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1214+
#[rustc_allow_const_fn_unstable(set_ptr_value)]
12081215
pub const fn wrapping_byte_sub(self, count: usize) -> Self {
12091216
self.cast::<u8>().wrapping_sub(count).with_metadata_of(self)
12101217
}
@@ -1372,7 +1379,6 @@ impl<T: ?Sized> *const T {
13721379
///
13731380
/// ```
13741381
/// #![feature(pointer_is_aligned)]
1375-
/// #![feature(pointer_byte_offsets)]
13761382
///
13771383
/// // On some platforms, the alignment of i32 is less than 4.
13781384
/// #[repr(align(4))]
@@ -1494,7 +1500,6 @@ impl<T: ?Sized> *const T {
14941500
///
14951501
/// ```
14961502
/// #![feature(pointer_is_aligned)]
1497-
/// #![feature(pointer_byte_offsets)]
14981503
///
14991504
/// // On some platforms, the alignment of i32 is less than 4.
15001505
/// #[repr(align(4))]

library/core/src/ptr/mut_ptr.rs

+21-16
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,9 @@ impl<T: ?Sized> *mut T {
495495
/// leaving the metadata untouched.
496496
#[must_use]
497497
#[inline(always)]
498-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
499-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
498+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
499+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
500+
#[rustc_allow_const_fn_unstable(set_ptr_value)]
500501
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
501502
pub const unsafe fn byte_offset(self, count: isize) -> Self {
502503
// SAFETY: the caller must uphold the safety contract for `offset`.
@@ -574,8 +575,9 @@ impl<T: ?Sized> *mut T {
574575
/// leaving the metadata untouched.
575576
#[must_use]
576577
#[inline(always)]
577-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
578-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
578+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
579+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
580+
#[rustc_allow_const_fn_unstable(set_ptr_value)]
579581
pub const fn wrapping_byte_offset(self, count: isize) -> Self {
580582
self.cast::<u8>().wrapping_offset(count).with_metadata_of(self)
581583
}
@@ -898,8 +900,9 @@ impl<T: ?Sized> *mut T {
898900
/// For non-`Sized` pointees this operation considers only the data pointers,
899901
/// ignoring the metadata.
900902
#[inline(always)]
901-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
902-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
903+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
904+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
905+
#[rustc_allow_const_fn_unstable(set_ptr_value)]
903906
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
904907
pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize {
905908
// SAFETY: the caller must uphold the safety contract for `offset_from`.
@@ -1053,8 +1056,9 @@ impl<T: ?Sized> *mut T {
10531056
/// leaving the metadata untouched.
10541057
#[must_use]
10551058
#[inline(always)]
1056-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
1057-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
1059+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1060+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1061+
#[rustc_allow_const_fn_unstable(set_ptr_value)]
10581062
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
10591063
pub const unsafe fn byte_add(self, count: usize) -> Self {
10601064
// SAFETY: the caller must uphold the safety contract for `add`.
@@ -1146,8 +1150,9 @@ impl<T: ?Sized> *mut T {
11461150
/// leaving the metadata untouched.
11471151
#[must_use]
11481152
#[inline(always)]
1149-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
1150-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
1153+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1154+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1155+
#[rustc_allow_const_fn_unstable(set_ptr_value)]
11511156
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
11521157
pub const unsafe fn byte_sub(self, count: usize) -> Self {
11531158
// SAFETY: the caller must uphold the safety contract for `sub`.
@@ -1226,8 +1231,9 @@ impl<T: ?Sized> *mut T {
12261231
/// leaving the metadata untouched.
12271232
#[must_use]
12281233
#[inline(always)]
1229-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
1230-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
1234+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1235+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1236+
#[rustc_allow_const_fn_unstable(set_ptr_value)]
12311237
pub const fn wrapping_byte_add(self, count: usize) -> Self {
12321238
self.cast::<u8>().wrapping_add(count).with_metadata_of(self)
12331239
}
@@ -1304,8 +1310,9 @@ impl<T: ?Sized> *mut T {
13041310
/// leaving the metadata untouched.
13051311
#[must_use]
13061312
#[inline(always)]
1307-
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
1308-
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
1313+
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1314+
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
1315+
#[rustc_allow_const_fn_unstable(set_ptr_value)]
13091316
pub const fn wrapping_byte_sub(self, count: usize) -> Self {
13101317
self.cast::<u8>().wrapping_sub(count).with_metadata_of(self)
13111318
}
@@ -1639,7 +1646,6 @@ impl<T: ?Sized> *mut T {
16391646
///
16401647
/// ```
16411648
/// #![feature(pointer_is_aligned)]
1642-
/// #![feature(pointer_byte_offsets)]
16431649
///
16441650
/// // On some platforms, the alignment of i32 is less than 4.
16451651
/// #[repr(align(4))]
@@ -1763,7 +1769,6 @@ impl<T: ?Sized> *mut T {
17631769
///
17641770
/// ```
17651771
/// #![feature(pointer_is_aligned)]
1766-
/// #![feature(pointer_byte_offsets)]
17671772
///
17681773
/// // On some platforms, the alignment of i32 is less than 4.
17691774
/// #[repr(align(4))]

library/core/tests/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![feature(const_heap)]
1717
#![feature(const_maybe_uninit_as_mut_ptr)]
1818
#![feature(const_nonnull_new)]
19-
#![feature(const_pointer_byte_offsets)]
2019
#![feature(const_pointer_is_aligned)]
2120
#![feature(const_ptr_as_ref)]
2221
#![feature(const_ptr_write)]
@@ -87,7 +86,6 @@
8786
#![feature(const_waker)]
8887
#![feature(never_type)]
8988
#![feature(unwrap_infallible)]
90-
#![feature(pointer_byte_offsets)]
9189
#![feature(pointer_is_aligned)]
9290
#![feature(portable_simd)]
9391
#![feature(ptr_metadata)]

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@
331331
#![feature(panic_can_unwind)]
332332
#![feature(panic_info_message)]
333333
#![feature(panic_internals)]
334-
#![feature(pointer_byte_offsets)]
335334
#![feature(pointer_is_aligned)]
336335
#![feature(portable_simd)]
337336
#![feature(prelude_2024)]

src/tools/miri/tests/fail/dangling_pointers/out_of_bounds_read.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(pointer_byte_offsets)]
2-
31
fn main() {
42
let v: Vec<u16> = vec![1, 2];
53
// This read is also misaligned. We make sure that the OOB message has priority.

src/tools/miri/tests/fail/dangling_pointers/out_of_bounds_write.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(pointer_byte_offsets)]
2-
31
fn main() {
42
let mut v: Vec<u16> = vec![1, 2];
53
// This read is also misaligned. We make sure that the OOB message has priority.

src/tools/miri/tests/pass/provenance.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@revisions: stack tree
22
//@[tree]compile-flags: -Zmiri-tree-borrows
33
#![feature(strict_provenance)]
4-
#![feature(pointer_byte_offsets)]
54
use std::{mem, ptr};
65

76
const PTR_SIZE: usize = mem::size_of::<&i32>();

tests/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,

tests/ui/const-ptr/forbidden_slices.rs

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#![feature(
66
slice_from_ptr_range,
77
const_slice_from_ptr_range,
8-
pointer_byte_offsets,
9-
const_pointer_byte_offsets
108
)]
119
use std::{
1210
mem::{size_of, MaybeUninit},

0 commit comments

Comments
 (0)