From ad93272627e216f352f9075f1ca72f4fd8febbed Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Wed, 20 Apr 2022 14:42:18 +1000 Subject: [PATCH 1/2] Stabilize `const_ptr_offset_from`. Stabilization has been completed [here](https://github.com/rust-lang/rust/issues/92980#issuecomment-1065644848) with a FCP. --- library/core/src/intrinsics.rs | 4 ++-- library/core/src/lib.rs | 1 - library/core/src/ptr/const_ptr.rs | 2 +- library/core/src/ptr/mut_ptr.rs | 2 +- src/test/ui/consts/const-eval/issue-91827-extern-types.rs | 1 - src/test/ui/consts/offset.rs | 1 - src/test/ui/consts/offset_from.rs | 1 - src/test/ui/consts/offset_from_ub.rs | 1 - 8 files changed, 4 insertions(+), 9 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 441d238268693..c0066ff62c6f5 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2013,11 +2013,11 @@ extern "rust-intrinsic" { pub fn nontemporal_store(ptr: *mut T, val: T); /// See documentation of `<*const T>::offset_from` for details. - #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")] + #[rustc_const_stable(feature = "const_ptr_offset_from", since = "1.65.0")] pub fn ptr_offset_from(ptr: *const T, base: *const T) -> isize; /// See documentation of `<*const T>::sub_ptr` for details. - #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")] + #[rustc_const_stable(feature = "const_ptr_offset_from", since = "1.65.0")] pub fn ptr_offset_from_unsigned(ptr: *const T, base: *const T) -> usize; /// See documentation of `<*const T>::guaranteed_eq` for details. diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 8d04a213f503d..60f38426baedf 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -130,7 +130,6 @@ #![feature(const_replace)] #![feature(const_ptr_as_ref)] #![feature(const_ptr_is_null)] -#![feature(const_ptr_offset_from)] #![feature(const_ptr_read)] #![feature(const_ptr_write)] #![feature(const_raw_ptr_comparison)] diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index c25b159c533a1..08fbb79fa654c 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -641,7 +641,7 @@ impl *const T { /// } /// ``` #[stable(feature = "ptr_offset_from", since = "1.47.0")] - #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")] + #[rustc_const_stable(feature = "const_ptr_offset_from", since = "1.65.0")] #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn offset_from(self, origin: *const T) -> isize diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index fff06b458c7c1..8467469053151 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -824,7 +824,7 @@ impl *mut T { /// } /// ``` #[stable(feature = "ptr_offset_from", since = "1.47.0")] - #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")] + #[rustc_const_stable(feature = "const_ptr_offset_from", since = "1.65.0")] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn offset_from(self, origin: *const T) -> isize diff --git a/src/test/ui/consts/const-eval/issue-91827-extern-types.rs b/src/test/ui/consts/const-eval/issue-91827-extern-types.rs index e1f5e8ae1453c..43c99799f7704 100644 --- a/src/test/ui/consts/const-eval/issue-91827-extern-types.rs +++ b/src/test/ui/consts/const-eval/issue-91827-extern-types.rs @@ -3,7 +3,6 @@ // Test that we can handle unsized types with an extern type tail part. // Regression test for issue #91827. -#![feature(const_ptr_offset_from)] #![feature(extern_types)] use std::ptr::addr_of; diff --git a/src/test/ui/consts/offset.rs b/src/test/ui/consts/offset.rs index f9ddda554fcf0..b2c663fe617a4 100644 --- a/src/test/ui/consts/offset.rs +++ b/src/test/ui/consts/offset.rs @@ -1,5 +1,4 @@ // run-pass -#![feature(const_ptr_offset_from)] use std::ptr; #[repr(C)] diff --git a/src/test/ui/consts/offset_from.rs b/src/test/ui/consts/offset_from.rs index b53718316f3b5..465147041d966 100644 --- a/src/test/ui/consts/offset_from.rs +++ b/src/test/ui/consts/offset_from.rs @@ -1,6 +1,5 @@ // run-pass -#![feature(const_ptr_offset_from)] #![feature(const_ptr_sub_ptr)] #![feature(ptr_sub_ptr)] diff --git a/src/test/ui/consts/offset_from_ub.rs b/src/test/ui/consts/offset_from_ub.rs index 1f29a690550bc..264bd631b3ba2 100644 --- a/src/test/ui/consts/offset_from_ub.rs +++ b/src/test/ui/consts/offset_from_ub.rs @@ -1,4 +1,3 @@ -#![feature(const_ptr_offset_from)] #![feature(core_intrinsics)] use std::intrinsics::{ptr_offset_from, ptr_offset_from_unsigned}; From 69ad63480820009278c470a67485e3505f03a633 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Thu, 12 May 2022 16:48:46 +1000 Subject: [PATCH 2/2] Do not include `const_ptr_sub_ptr` in this stabilization --- library/core/src/intrinsics.rs | 2 +- src/test/ui/consts/offset_from_ub.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index c0066ff62c6f5..e31c226e818be 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2017,7 +2017,7 @@ extern "rust-intrinsic" { pub fn ptr_offset_from(ptr: *const T, base: *const T) -> isize; /// See documentation of `<*const T>::sub_ptr` for details. - #[rustc_const_stable(feature = "const_ptr_offset_from", since = "1.65.0")] + #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] pub fn ptr_offset_from_unsigned(ptr: *const T, base: *const T) -> usize; /// See documentation of `<*const T>::guaranteed_eq` for details. diff --git a/src/test/ui/consts/offset_from_ub.rs b/src/test/ui/consts/offset_from_ub.rs index 264bd631b3ba2..51163e650d6aa 100644 --- a/src/test/ui/consts/offset_from_ub.rs +++ b/src/test/ui/consts/offset_from_ub.rs @@ -1,3 +1,4 @@ +#![feature(const_ptr_sub_ptr)] #![feature(core_intrinsics)] use std::intrinsics::{ptr_offset_from, ptr_offset_from_unsigned};