Skip to content

Commit 003b954

Browse files
committed
Apply CR suggestions; add real tracking issue
1 parent 4bb15b3 commit 003b954

File tree

6 files changed

+14
-10
lines changed

6 files changed

+14
-10
lines changed

compiler/rustc_const_eval/src/interpret/intrinsics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
377377
}
378378

379379
let pointee_layout = self.layout_of(substs.type_at(0))?;
380+
// This re-interprets an isize at ret_layout, but we already checked
381+
// that if ret_layout is usize, then the result must be non-negative.
380382
let val = ImmTy::from_scalar(val, ret_layout);
381383
let size = ImmTy::from_int(pointee_layout.size.bytes(), ret_layout);
382384
self.exact_div(&val, &size, dest)?;

library/alloc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
#![feature(pattern)]
128128
#![feature(ptr_internals)]
129129
#![feature(ptr_metadata)]
130-
#![feature(ptr_unsigned_offset_from)]
130+
#![feature(ptr_sub_ptr)]
131131
#![feature(receiver_trait)]
132132
#![feature(set_ptr_value)]
133133
#![feature(slice_group_by)]

library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
#![feature(const_option)]
127127
#![feature(const_option_ext)]
128128
#![feature(const_pin)]
129+
#![feature(const_ptr_sub_ptr)]
129130
#![feature(const_replace)]
130131
#![feature(const_ptr_as_ref)]
131132
#![feature(const_ptr_is_null)]

library/core/src/ptr/const_ptr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ impl<T: ?Sized> *const T {
627627
/// to [`sub`](#method.sub)). The following are all equivalent, assuming
628628
/// that their safety preconditions are met:
629629
/// ```rust
630-
/// # #![feature(ptr_unsigned_offset_from)]
630+
/// # #![feature(ptr_sub_ptr)]
631631
/// # unsafe fn blah(ptr: *const i32, origin: *const i32, count: usize) -> bool {
632632
/// ptr.sub_ptr(origin) == count
633633
/// # &&
@@ -656,7 +656,7 @@ impl<T: ?Sized> *const T {
656656
/// # Examples
657657
///
658658
/// ```
659-
/// #![feature(ptr_unsigned_offset_from)]
659+
/// #![feature(ptr_sub_ptr)]
660660
///
661661
/// let a = [0; 5];
662662
/// let ptr1: *const i32 = &a[1];
@@ -671,8 +671,8 @@ impl<T: ?Sized> *const T {
671671
/// // This would be incorrect, as the pointers are not correctly ordered:
672672
/// // ptr1.offset_from(ptr2)
673673
/// ```
674-
#[unstable(feature = "ptr_unsigned_offset_from", issue = "88888888")]
675-
#[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")]
674+
#[unstable(feature = "ptr_sub_ptr", issue = "95892")]
675+
#[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
676676
#[inline]
677677
pub const unsafe fn sub_ptr(self, origin: *const T) -> usize
678678
where

library/core/src/ptr/mut_ptr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ impl<T: ?Sized> *mut T {
803803
/// to [`sub`](#method.sub)). The following are all equivalent, assuming
804804
/// that their safety preconditions are met:
805805
/// ```rust
806-
/// # #![feature(ptr_unsigned_offset_from)]
806+
/// # #![feature(ptr_sub_ptr)]
807807
/// # unsafe fn blah(ptr: *mut i32, origin: *mut i32, count: usize) -> bool {
808808
/// ptr.sub_ptr(origin) == count
809809
/// # &&
@@ -832,7 +832,7 @@ impl<T: ?Sized> *mut T {
832832
/// # Examples
833833
///
834834
/// ```
835-
/// #![feature(ptr_unsigned_offset_from)]
835+
/// #![feature(ptr_sub_ptr)]
836836
///
837837
/// let mut a = [0; 5];
838838
/// let p: *mut i32 = a.as_mut_ptr();
@@ -848,8 +848,8 @@ impl<T: ?Sized> *mut T {
848848
///
849849
/// // This would be incorrect, as the pointers are not correctly ordered:
850850
/// // ptr1.offset_from(ptr2)
851-
#[unstable(feature = "ptr_unsigned_offset_from", issue = "88888888")]
852-
#[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")]
851+
#[unstable(feature = "ptr_sub_ptr", issue = "95892")]
852+
#[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
853853
#[inline]
854854
pub const unsafe fn sub_ptr(self, origin: *const T) -> usize
855855
where

src/test/ui/consts/offset_from.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// run-pass
22

33
#![feature(const_ptr_offset_from)]
4-
#![feature(ptr_unsigned_offset_from)]
4+
#![feature(const_ptr_sub_ptr)]
5+
#![feature(ptr_sub_ptr)]
56

67
struct Struct {
78
field: (),

0 commit comments

Comments
 (0)