Skip to content

Commit 0eef482

Browse files
bend-ngitbot
authored and
gitbot
committed
stabilize (const_)ptr_sub_ptr
1 parent 83ea586 commit 0eef482

File tree

5 files changed

+13
-21
lines changed

5 files changed

+13
-21
lines changed

alloc/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@
137137
#![feature(pointer_like_trait)]
138138
#![feature(ptr_internals)]
139139
#![feature(ptr_metadata)]
140-
#![feature(ptr_sub_ptr)]
141140
#![feature(set_ptr_value)]
142141
#![feature(sized_type_properties)]
143142
#![feature(slice_from_ptr_range)]

core/src/intrinsics/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3675,6 +3675,7 @@ pub const unsafe fn ptr_offset_from<T>(_ptr: *const T, _base: *const T) -> isize
36753675
#[rustc_nounwind]
36763676
#[rustc_intrinsic]
36773677
#[rustc_intrinsic_must_be_overridden]
3678+
#[rustc_intrinsic_const_stable_indirect]
36783679
pub const unsafe fn ptr_offset_from_unsigned<T>(_ptr: *const T, _base: *const T) -> usize {
36793680
unimplemented!()
36803681
}

core/src/ptr/const_ptr.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,6 @@ impl<T: ?Sized> *const T {
723723
/// to [`sub`](#method.sub)). The following are all equivalent, assuming
724724
/// that their safety preconditions are met:
725725
/// ```rust
726-
/// # #![feature(ptr_sub_ptr)]
727726
/// # unsafe fn blah(ptr: *const i32, origin: *const i32, count: usize) -> bool { unsafe {
728727
/// ptr.sub_ptr(origin) == count
729728
/// # &&
@@ -752,8 +751,6 @@ impl<T: ?Sized> *const T {
752751
/// # Examples
753752
///
754753
/// ```
755-
/// #![feature(ptr_sub_ptr)]
756-
///
757754
/// let a = [0; 5];
758755
/// let ptr1: *const i32 = &a[1];
759756
/// let ptr2: *const i32 = &a[3];
@@ -767,8 +764,8 @@ impl<T: ?Sized> *const T {
767764
/// // This would be incorrect, as the pointers are not correctly ordered:
768765
/// // ptr1.sub_ptr(ptr2)
769766
/// ```
770-
#[unstable(feature = "ptr_sub_ptr", issue = "95892")]
771-
#[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
767+
#[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")]
768+
#[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")]
772769
#[inline]
773770
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
774771
pub const unsafe fn sub_ptr(self, origin: *const T) -> usize
@@ -812,8 +809,8 @@ impl<T: ?Sized> *const T {
812809
///
813810
/// For non-`Sized` pointees this operation considers only the data pointers,
814811
/// ignoring the metadata.
815-
#[unstable(feature = "ptr_sub_ptr", issue = "95892")]
816-
#[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
812+
#[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")]
813+
#[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")]
817814
#[inline]
818815
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
819816
pub const unsafe fn byte_sub_ptr<U: ?Sized>(self, origin: *const U) -> usize {

core/src/ptr/mut_ptr.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,6 @@ impl<T: ?Sized> *mut T {
895895
/// to [`sub`](#method.sub)). The following are all equivalent, assuming
896896
/// that their safety preconditions are met:
897897
/// ```rust
898-
/// # #![feature(ptr_sub_ptr)]
899898
/// # unsafe fn blah(ptr: *mut i32, origin: *mut i32, count: usize) -> bool { unsafe {
900899
/// ptr.sub_ptr(origin) == count
901900
/// # &&
@@ -924,8 +923,6 @@ impl<T: ?Sized> *mut T {
924923
/// # Examples
925924
///
926925
/// ```
927-
/// #![feature(ptr_sub_ptr)]
928-
///
929926
/// let mut a = [0; 5];
930927
/// let p: *mut i32 = a.as_mut_ptr();
931928
/// unsafe {
@@ -940,8 +937,8 @@ impl<T: ?Sized> *mut T {
940937
///
941938
/// // This would be incorrect, as the pointers are not correctly ordered:
942939
/// // ptr1.offset_from(ptr2)
943-
#[unstable(feature = "ptr_sub_ptr", issue = "95892")]
944-
#[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
940+
#[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")]
941+
#[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")]
945942
#[inline]
946943
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
947944
pub const unsafe fn sub_ptr(self, origin: *const T) -> usize
@@ -962,8 +959,8 @@ impl<T: ?Sized> *mut T {
962959
///
963960
/// For non-`Sized` pointees this operation considers only the data pointers,
964961
/// ignoring the metadata.
965-
#[unstable(feature = "ptr_sub_ptr", issue = "95892")]
966-
#[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
962+
#[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")]
963+
#[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")]
967964
#[inline]
968965
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
969966
pub const unsafe fn byte_sub_ptr<U: ?Sized>(self, origin: *mut U) -> usize {

core/src/ptr/non_null.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,6 @@ impl<T: ?Sized> NonNull<T> {
856856
/// to [`sub`](#method.sub)). The following are all equivalent, assuming
857857
/// that their safety preconditions are met:
858858
/// ```rust
859-
/// # #![feature(ptr_sub_ptr)]
860859
/// # unsafe fn blah(ptr: std::ptr::NonNull<u32>, origin: std::ptr::NonNull<u32>, count: usize) -> bool { unsafe {
861860
/// ptr.sub_ptr(origin) == count
862861
/// # &&
@@ -885,7 +884,6 @@ impl<T: ?Sized> NonNull<T> {
885884
/// # Examples
886885
///
887886
/// ```
888-
/// #![feature(ptr_sub_ptr)]
889887
/// use std::ptr::NonNull;
890888
///
891889
/// let a = [0; 5];
@@ -903,8 +901,8 @@ impl<T: ?Sized> NonNull<T> {
903901
/// ```
904902
#[inline]
905903
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
906-
#[unstable(feature = "ptr_sub_ptr", issue = "95892")]
907-
#[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
904+
#[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")]
905+
#[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")]
908906
pub const unsafe fn sub_ptr(self, subtracted: NonNull<T>) -> usize
909907
where
910908
T: Sized,
@@ -925,8 +923,8 @@ impl<T: ?Sized> NonNull<T> {
925923
/// ignoring the metadata.
926924
#[inline(always)]
927925
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
928-
#[unstable(feature = "ptr_sub_ptr", issue = "95892")]
929-
#[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
926+
#[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")]
927+
#[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")]
930928
pub const unsafe fn byte_sub_ptr<U: ?Sized>(self, origin: NonNull<U>) -> usize {
931929
// SAFETY: the caller must uphold the safety contract for `byte_sub_ptr`.
932930
unsafe { self.as_ptr().byte_sub_ptr(origin.as_ptr()) }

0 commit comments

Comments
 (0)