diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2022-04-10 16:02:52 -0700 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2022-05-11 17:16:25 -0700 |
| commit | 003b954a43a7f1f9058f25e8f9b6ddfd4a3dced9 (patch) | |
| tree | 0f7e59be0a498f30146cc7290339125802f91f6a | |
| parent | 4bb15b3797452b87c6ea3189fa60dd52d59a567d (diff) | |
| download | rust-003b954a43a7f1f9058f25e8f9b6ddfd4a3dced9.tar.gz rust-003b954a43a7f1f9058f25e8f9b6ddfd4a3dced9.zip | |
Apply CR suggestions; add real tracking issue
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/intrinsics.rs | 2 | ||||
| -rw-r--r-- | library/alloc/src/lib.rs | 2 | ||||
| -rw-r--r-- | library/core/src/lib.rs | 1 | ||||
| -rw-r--r-- | library/core/src/ptr/const_ptr.rs | 8 | ||||
| -rw-r--r-- | library/core/src/ptr/mut_ptr.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/consts/offset_from.rs | 3 |
6 files changed, 14 insertions, 10 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index 3bb3b3d5393..59ea40dc2f9 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -377,6 +377,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } let pointee_layout = self.layout_of(substs.type_at(0))?; + // This re-interprets an isize at ret_layout, but we already checked + // that if ret_layout is usize, then the result must be non-negative. let val = ImmTy::from_scalar(val, ret_layout); let size = ImmTy::from_int(pointee_layout.size.bytes(), ret_layout); self.exact_div(&val, &size, dest)?; diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 1c569e15607..fd21b367118 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -127,7 +127,7 @@ #![feature(pattern)] #![feature(ptr_internals)] #![feature(ptr_metadata)] -#![feature(ptr_unsigned_offset_from)] +#![feature(ptr_sub_ptr)] #![feature(receiver_trait)] #![feature(set_ptr_value)] #![feature(slice_group_by)] diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 1612aa582ad..d1936b6b566 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -126,6 +126,7 @@ #![feature(const_option)] #![feature(const_option_ext)] #![feature(const_pin)] +#![feature(const_ptr_sub_ptr)] #![feature(const_replace)] #![feature(const_ptr_as_ref)] #![feature(const_ptr_is_null)] diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 7fcdf21b03c..028adc796e5 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -627,7 +627,7 @@ impl<T: ?Sized> *const T { /// to [`sub`](#method.sub)). The following are all equivalent, assuming /// that their safety preconditions are met: /// ```rust - /// # #![feature(ptr_unsigned_offset_from)] + /// # #![feature(ptr_sub_ptr)] /// # unsafe fn blah(ptr: *const i32, origin: *const i32, count: usize) -> bool { /// ptr.sub_ptr(origin) == count /// # && @@ -656,7 +656,7 @@ impl<T: ?Sized> *const T { /// # Examples /// /// ``` - /// #![feature(ptr_unsigned_offset_from)] + /// #![feature(ptr_sub_ptr)] /// /// let a = [0; 5]; /// let ptr1: *const i32 = &a[1]; @@ -671,8 +671,8 @@ impl<T: ?Sized> *const T { /// // This would be incorrect, as the pointers are not correctly ordered: /// // ptr1.offset_from(ptr2) /// ``` - #[unstable(feature = "ptr_unsigned_offset_from", issue = "88888888")] - #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")] + #[unstable(feature = "ptr_sub_ptr", issue = "95892")] + #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] #[inline] pub const unsafe fn sub_ptr(self, origin: *const T) -> usize where diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index c7f297f426b..1a32dd62dfd 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -803,7 +803,7 @@ impl<T: ?Sized> *mut T { /// to [`sub`](#method.sub)). The following are all equivalent, assuming /// that their safety preconditions are met: /// ```rust - /// # #![feature(ptr_unsigned_offset_from)] + /// # #![feature(ptr_sub_ptr)] /// # unsafe fn blah(ptr: *mut i32, origin: *mut i32, count: usize) -> bool { /// ptr.sub_ptr(origin) == count /// # && @@ -832,7 +832,7 @@ impl<T: ?Sized> *mut T { /// # Examples /// /// ``` - /// #![feature(ptr_unsigned_offset_from)] + /// #![feature(ptr_sub_ptr)] /// /// let mut a = [0; 5]; /// let p: *mut i32 = a.as_mut_ptr(); @@ -848,8 +848,8 @@ impl<T: ?Sized> *mut T { /// /// // This would be incorrect, as the pointers are not correctly ordered: /// // ptr1.offset_from(ptr2) - #[unstable(feature = "ptr_unsigned_offset_from", issue = "88888888")] - #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")] + #[unstable(feature = "ptr_sub_ptr", issue = "95892")] + #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] #[inline] pub const unsafe fn sub_ptr(self, origin: *const T) -> usize where diff --git a/src/test/ui/consts/offset_from.rs b/src/test/ui/consts/offset_from.rs index ad834e885a5..b53718316f3 100644 --- a/src/test/ui/consts/offset_from.rs +++ b/src/test/ui/consts/offset_from.rs @@ -1,7 +1,8 @@ // run-pass #![feature(const_ptr_offset_from)] -#![feature(ptr_unsigned_offset_from)] +#![feature(const_ptr_sub_ptr)] +#![feature(ptr_sub_ptr)] struct Struct { field: (), |
