Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bea08ae

Browse files
authoredMar 26, 2022
Rollup merge of rust-lang#93957 - SaltyKitkat:stablize_const_ptr_offset, r=dtolnay
Stabilize const_ptr_offset Close rust-lang#71499
2 parents 1d9c262 + e5d1d97 commit bea08ae

20 files changed

+61
-68
lines changed
 

‎library/alloc/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#![feature(const_intrinsic_copy)]
1111
#![feature(const_mut_refs)]
1212
#![feature(const_nonnull_slice_from_raw_parts)]
13-
#![feature(const_ptr_offset)]
1413
#![feature(const_ptr_write)]
1514
#![feature(const_try)]
1615
#![feature(core_intrinsics)]

‎library/core/src/intrinsics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ extern "rust-intrinsic" {
11681168
///
11691169
/// The stabilized version of this intrinsic is [`pointer::offset`].
11701170
#[must_use = "returns a new pointer rather than modifying its argument"]
1171-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
1171+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
11721172
pub fn offset<T>(dst: *const T, offset: isize) -> *const T;
11731173

11741174
/// Calculates the offset from a pointer, potentially wrapping.
@@ -1185,7 +1185,7 @@ extern "rust-intrinsic" {
11851185
///
11861186
/// The stabilized version of this intrinsic is [`pointer::wrapping_offset`].
11871187
#[must_use = "returns a new pointer rather than modifying its argument"]
1188-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
1188+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
11891189
pub fn arith_offset<T>(dst: *const T, offset: isize) -> *const T;
11901190

11911191
/// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with

‎library/core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@
126126
#![feature(const_pin)]
127127
#![feature(const_replace)]
128128
#![feature(const_ptr_is_null)]
129-
#![feature(const_ptr_offset)]
130129
#![feature(const_ptr_offset_from)]
131130
#![feature(const_ptr_read)]
132131
#![feature(const_ptr_write)]

‎library/core/src/ptr/const_ptr.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl<T: ?Sized> *const T {
285285
/// ```
286286
#[stable(feature = "rust1", since = "1.0.0")]
287287
#[must_use = "returns a new pointer rather than modifying its argument"]
288-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
288+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
289289
#[inline(always)]
290290
pub const unsafe fn offset(self, count: isize) -> *const T
291291
where
@@ -347,7 +347,7 @@ impl<T: ?Sized> *const T {
347347
/// ```
348348
#[stable(feature = "ptr_wrapping_offset", since = "1.16.0")]
349349
#[must_use = "returns a new pointer rather than modifying its argument"]
350-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
350+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
351351
#[inline(always)]
352352
pub const fn wrapping_offset(self, count: isize) -> *const T
353353
where
@@ -566,7 +566,7 @@ impl<T: ?Sized> *const T {
566566
/// ```
567567
#[stable(feature = "pointer_methods", since = "1.26.0")]
568568
#[must_use = "returns a new pointer rather than modifying its argument"]
569-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
569+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
570570
#[inline(always)]
571571
pub const unsafe fn add(self, count: usize) -> Self
572572
where
@@ -630,7 +630,7 @@ impl<T: ?Sized> *const T {
630630
/// ```
631631
#[stable(feature = "pointer_methods", since = "1.26.0")]
632632
#[must_use = "returns a new pointer rather than modifying its argument"]
633-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
633+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
634634
#[inline]
635635
pub const unsafe fn sub(self, count: usize) -> Self
636636
where
@@ -693,7 +693,7 @@ impl<T: ?Sized> *const T {
693693
/// ```
694694
#[stable(feature = "pointer_methods", since = "1.26.0")]
695695
#[must_use = "returns a new pointer rather than modifying its argument"]
696-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
696+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
697697
#[inline(always)]
698698
pub const fn wrapping_add(self, count: usize) -> Self
699699
where
@@ -755,7 +755,7 @@ impl<T: ?Sized> *const T {
755755
/// ```
756756
#[stable(feature = "pointer_methods", since = "1.26.0")]
757757
#[must_use = "returns a new pointer rather than modifying its argument"]
758-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
758+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
759759
#[inline]
760760
pub const fn wrapping_sub(self, count: usize) -> Self
761761
where

‎library/core/src/ptr/mut_ptr.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl<T: ?Sized> *mut T {
295295
/// ```
296296
#[stable(feature = "rust1", since = "1.0.0")]
297297
#[must_use = "returns a new pointer rather than modifying its argument"]
298-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
298+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
299299
#[inline(always)]
300300
pub const unsafe fn offset(self, count: isize) -> *mut T
301301
where
@@ -358,7 +358,7 @@ impl<T: ?Sized> *mut T {
358358
/// ```
359359
#[stable(feature = "ptr_wrapping_offset", since = "1.16.0")]
360360
#[must_use = "returns a new pointer rather than modifying its argument"]
361-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
361+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
362362
#[inline(always)]
363363
pub const fn wrapping_offset(self, count: isize) -> *mut T
364364
where
@@ -680,7 +680,7 @@ impl<T: ?Sized> *mut T {
680680
/// ```
681681
#[stable(feature = "pointer_methods", since = "1.26.0")]
682682
#[must_use = "returns a new pointer rather than modifying its argument"]
683-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
683+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
684684
#[inline(always)]
685685
pub const unsafe fn add(self, count: usize) -> Self
686686
where
@@ -744,7 +744,7 @@ impl<T: ?Sized> *mut T {
744744
/// ```
745745
#[stable(feature = "pointer_methods", since = "1.26.0")]
746746
#[must_use = "returns a new pointer rather than modifying its argument"]
747-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
747+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
748748
#[inline]
749749
pub const unsafe fn sub(self, count: usize) -> Self
750750
where
@@ -807,7 +807,7 @@ impl<T: ?Sized> *mut T {
807807
/// ```
808808
#[stable(feature = "pointer_methods", since = "1.26.0")]
809809
#[must_use = "returns a new pointer rather than modifying its argument"]
810-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
810+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
811811
#[inline(always)]
812812
pub const fn wrapping_add(self, count: usize) -> Self
813813
where
@@ -869,7 +869,7 @@ impl<T: ?Sized> *mut T {
869869
/// ```
870870
#[stable(feature = "pointer_methods", since = "1.26.0")]
871871
#[must_use = "returns a new pointer rather than modifying its argument"]
872-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
872+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
873873
#[inline]
874874
pub const fn wrapping_sub(self, count: usize) -> Self
875875
where

‎library/core/src/slice/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,8 @@ impl<T> [T] {
499499
/// assert_eq!(x, &[3, 4, 6]);
500500
/// ```
501501
#[stable(feature = "rust1", since = "1.0.0")]
502-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
502+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
503+
#[rustc_allow_const_fn_unstable(const_mut_refs)]
503504
#[inline]
504505
#[must_use]
505506
pub const fn as_mut_ptr(&mut self) -> *mut T {
@@ -535,7 +536,7 @@ impl<T> [T] {
535536
///
536537
/// [`as_ptr`]: slice::as_ptr
537538
#[stable(feature = "slice_ptr_range", since = "1.48.0")]
538-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
539+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
539540
#[inline]
540541
#[must_use]
541542
pub const fn as_ptr_range(&self) -> Range<*const T> {
@@ -578,7 +579,8 @@ impl<T> [T] {
578579
///
579580
/// [`as_mut_ptr`]: slice::as_mut_ptr
580581
#[stable(feature = "slice_ptr_range", since = "1.48.0")]
581-
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
582+
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
583+
#[rustc_allow_const_fn_unstable(const_mut_refs)]
582584
#[inline]
583585
#[must_use]
584586
pub const fn as_mut_ptr_range(&mut self) -> Range<*mut T> {

‎library/core/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#![feature(const_ptr_as_ref)]
2121
#![feature(const_ptr_read)]
2222
#![feature(const_ptr_write)]
23-
#![feature(const_ptr_offset)]
2423
#![feature(const_trait_impl)]
2524
#![feature(const_likely)]
2625
#![feature(core_ffi_c)]

‎src/test/ui/const-ptr/out_of_bounds_read.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// error-pattern: evaluation of constant value failed
22

33
#![feature(const_ptr_read)]
4-
#![feature(const_ptr_offset)]
54

65
fn main() {
76
use std::ptr;

‎src/test/ui/const-ptr/out_of_bounds_read.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1);
77
| memory access failed: alloc7 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds
88
| inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
99
|
10-
::: $DIR/out_of_bounds_read.rs:13:33
10+
::: $DIR/out_of_bounds_read.rs:12:33
1111
|
1212
LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
13-
| ----------------------- inside `_READ` at $DIR/out_of_bounds_read.rs:13:33
13+
| ----------------------- inside `_READ` at $DIR/out_of_bounds_read.rs:12:33
1414

1515
error[E0080]: evaluation of constant value failed
1616
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
@@ -26,10 +26,10 @@ LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1);
2626
LL | unsafe { read(self) }
2727
| ---------- inside `ptr::const_ptr::<impl *const u32>::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
2828
|
29-
::: $DIR/out_of_bounds_read.rs:14:39
29+
::: $DIR/out_of_bounds_read.rs:13:39
3030
|
3131
LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
32-
| ------------------- inside `_CONST_READ` at $DIR/out_of_bounds_read.rs:14:39
32+
| ------------------- inside `_CONST_READ` at $DIR/out_of_bounds_read.rs:13:39
3333

3434
error[E0080]: evaluation of constant value failed
3535
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
@@ -45,10 +45,10 @@ LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1);
4545
LL | unsafe { read(self) }
4646
| ---------- inside `ptr::mut_ptr::<impl *mut u32>::read` at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
4747
|
48-
::: $DIR/out_of_bounds_read.rs:15:37
48+
::: $DIR/out_of_bounds_read.rs:14:37
4949
|
5050
LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
51-
| --------------------------------- inside `_MUT_READ` at $DIR/out_of_bounds_read.rs:15:37
51+
| --------------------------------- inside `_MUT_READ` at $DIR/out_of_bounds_read.rs:14:37
5252

5353
error: aborting due to 3 previous errors
5454

‎src/test/ui/consts/copy-intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// ignore-tidy-linelength
44
#![feature(intrinsics, staged_api)]
5-
#![feature(const_mut_refs, const_intrinsic_copy, const_ptr_offset)]
5+
#![feature(const_mut_refs, const_intrinsic_copy)]
66
use std::mem;
77

88
extern "rust-intrinsic" {

‎src/test/ui/consts/invalid-union.32bit.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0080]: it is undefined behavior to use this value
2-
--> $DIR/invalid-union.rs:41:1
2+
--> $DIR/invalid-union.rs:40:1
33
|
44
LL | fn main() {
55
| ^^^^^^^^^ type validation failed at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in a `const`
@@ -10,7 +10,7 @@ LL | fn main() {
1010
}
1111

1212
error: erroneous constant used
13-
--> $DIR/invalid-union.rs:42:25
13+
--> $DIR/invalid-union.rs:41:25
1414
|
1515
LL | let _: &'static _ = &C;
1616
| ^^ referenced constant has errors

‎src/test/ui/consts/invalid-union.64bit.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0080]: it is undefined behavior to use this value
2-
--> $DIR/invalid-union.rs:41:1
2+
--> $DIR/invalid-union.rs:40:1
33
|
44
LL | fn main() {
55
| ^^^^^^^^^ type validation failed at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in a `const`
@@ -10,7 +10,7 @@ LL | fn main() {
1010
}
1111

1212
error: erroneous constant used
13-
--> $DIR/invalid-union.rs:42:25
13+
--> $DIR/invalid-union.rs:41:25
1414
|
1515
LL | let _: &'static _ = &C;
1616
| ^^ referenced constant has errors

‎src/test/ui/consts/invalid-union.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// build-fail
1010
// stderr-per-bitwidth
1111
#![feature(const_mut_refs)]
12-
#![feature(const_ptr_offset)]
1312
#![feature(untagged_unions)]
1413
use std::cell::Cell;
1514

‎src/test/ui/consts/issue-miri-1910.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// error-pattern unable to turn pointer into raw bytes
22
#![feature(const_ptr_read)]
3-
#![feature(const_ptr_offset)]
43

54
const C: () = unsafe {
65
let foo = Some(&42 as *const i32);

‎src/test/ui/consts/issue-miri-1910.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1);
77
| unable to turn pointer into raw bytes
88
| inside `std::ptr::read::<u8>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
99
| inside `ptr::const_ptr::<impl *const u8>::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
10-
| inside `C` at $DIR/issue-miri-1910.rs:8:5
10+
| inside `C` at $DIR/issue-miri-1910.rs:7:5
1111
|
12-
::: $DIR/issue-miri-1910.rs:5:1
12+
::: $DIR/issue-miri-1910.rs:4:1
1313
|
1414
LL | / const C: () = unsafe {
1515
LL | | let foo = Some(&42 as *const i32);

‎src/test/ui/consts/offset.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// run-pass
2-
#![feature(const_ptr_offset)]
32
#![feature(const_ptr_offset_from)]
43
use std::ptr;
54

‎src/test/ui/consts/offset_ub.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(const_ptr_offset)]
21
use std::ptr;
32

43
// normalize-stderr-test "alloc\d+" -> "allocN"

‎src/test/ui/consts/offset_ub.stderr

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ LL | unsafe { intrinsics::offset(self, count) }
77
| overflowing in-bounds pointer arithmetic
88
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
99
|
10-
::: $DIR/offset_ub.rs:8:46
10+
::: $DIR/offset_ub.rs:7:46
1111
|
1212
LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) };
13-
| ------------------------------ inside `BEFORE_START` at $DIR/offset_ub.rs:8:46
13+
| ------------------------------ inside `BEFORE_START` at $DIR/offset_ub.rs:7:46
1414

1515
error[E0080]: evaluation of constant value failed
1616
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -21,10 +21,10 @@ LL | unsafe { intrinsics::offset(self, count) }
2121
| pointer arithmetic failed: allocN has size 1, so pointer to 2 bytes starting at offset 0 is out-of-bounds
2222
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
2323
|
24-
::: $DIR/offset_ub.rs:9:43
24+
::: $DIR/offset_ub.rs:8:43
2525
|
2626
LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) };
27-
| ----------------------------- inside `AFTER_END` at $DIR/offset_ub.rs:9:43
27+
| ----------------------------- inside `AFTER_END` at $DIR/offset_ub.rs:8:43
2828

2929
error[E0080]: evaluation of constant value failed
3030
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -35,10 +35,10 @@ LL | unsafe { intrinsics::offset(self, count) }
3535
| pointer arithmetic failed: allocN has size 100, so pointer to 101 bytes starting at offset 0 is out-of-bounds
3636
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
3737
|
38-
::: $DIR/offset_ub.rs:10:45
38+
::: $DIR/offset_ub.rs:9:45
3939
|
4040
LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) };
41-
| ------------------------------- inside `AFTER_ARRAY` at $DIR/offset_ub.rs:10:45
41+
| ------------------------------- inside `AFTER_ARRAY` at $DIR/offset_ub.rs:9:45
4242

4343
error[E0080]: evaluation of constant value failed
4444
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -49,10 +49,10 @@ LL | unsafe { intrinsics::offset(self, count) }
4949
| overflowing in-bounds pointer arithmetic
5050
| inside `ptr::const_ptr::<impl *const u16>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
5151
|
52-
::: $DIR/offset_ub.rs:12:43
52+
::: $DIR/offset_ub.rs:11:43
5353
|
5454
LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) };
55-
| ------------------------------------- inside `OVERFLOW` at $DIR/offset_ub.rs:12:43
55+
| ------------------------------------- inside `OVERFLOW` at $DIR/offset_ub.rs:11:43
5656

5757
error[E0080]: evaluation of constant value failed
5858
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -63,10 +63,10 @@ LL | unsafe { intrinsics::offset(self, count) }
6363
| overflowing in-bounds pointer arithmetic
6464
| inside `ptr::const_ptr::<impl *const u16>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
6565
|
66-
::: $DIR/offset_ub.rs:13:44
66+
::: $DIR/offset_ub.rs:12:44
6767
|
6868
LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) };
69-
| ------------------------------------- inside `UNDERFLOW` at $DIR/offset_ub.rs:13:44
69+
| ------------------------------------- inside `UNDERFLOW` at $DIR/offset_ub.rs:12:44
7070

7171
error[E0080]: evaluation of constant value failed
7272
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -77,10 +77,10 @@ LL | unsafe { intrinsics::offset(self, count) }
7777
| overflowing in-bounds pointer arithmetic
7878
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
7979
|
80-
::: $DIR/offset_ub.rs:14:56
80+
::: $DIR/offset_ub.rs:13:56
8181
|
8282
LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) };
83-
| ----------------------------------- inside `OVERFLOW_ADDRESS_SPACE` at $DIR/offset_ub.rs:14:56
83+
| ----------------------------------- inside `OVERFLOW_ADDRESS_SPACE` at $DIR/offset_ub.rs:13:56
8484

8585
error[E0080]: evaluation of constant value failed
8686
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -91,10 +91,10 @@ LL | unsafe { intrinsics::offset(self, count) }
9191
| overflowing in-bounds pointer arithmetic
9292
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
9393
|
94-
::: $DIR/offset_ub.rs:15:57
94+
::: $DIR/offset_ub.rs:14:57
9595
|
9696
LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) };
97-
| --------------------------- inside `UNDERFLOW_ADDRESS_SPACE` at $DIR/offset_ub.rs:15:57
97+
| --------------------------- inside `UNDERFLOW_ADDRESS_SPACE` at $DIR/offset_ub.rs:14:57
9898

9999
error[E0080]: evaluation of constant value failed
100100
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -105,10 +105,10 @@ LL | unsafe { intrinsics::offset(self, count) }
105105
| pointer arithmetic failed: allocN has size 1, so pointer to 2 bytes starting at offset -4 is out-of-bounds
106106
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
107107
|
108-
::: $DIR/offset_ub.rs:16:49
108+
::: $DIR/offset_ub.rs:15:49
109109
|
110110
LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) };
111-
| ------------------------------------------------ inside `NEGATIVE_OFFSET` at $DIR/offset_ub.rs:16:49
111+
| ------------------------------------------------ inside `NEGATIVE_OFFSET` at $DIR/offset_ub.rs:15:49
112112

113113
error[E0080]: evaluation of constant value failed
114114
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -119,10 +119,10 @@ LL | unsafe { intrinsics::offset(self, count) }
119119
| pointer arithmetic failed: allocN has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds
120120
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
121121
|
122-
::: $DIR/offset_ub.rs:18:50
122+
::: $DIR/offset_ub.rs:17:50
123123
|
124124
LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) };
125-
| --------------------------- inside `ZERO_SIZED_ALLOC` at $DIR/offset_ub.rs:18:50
125+
| --------------------------- inside `ZERO_SIZED_ALLOC` at $DIR/offset_ub.rs:17:50
126126

127127
error[E0080]: evaluation of constant value failed
128128
--> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
@@ -133,10 +133,10 @@ LL | unsafe { intrinsics::offset(self, count) as *mut T }
133133
| pointer arithmetic failed: 0x1 is not a valid pointer
134134
| inside `ptr::mut_ptr::<impl *mut u8>::offset` at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
135135
|
136-
::: $DIR/offset_ub.rs:19:42
136+
::: $DIR/offset_ub.rs:18:42
137137
|
138138
LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) };
139-
| ------------------------------------------------- inside `DANGLING` at $DIR/offset_ub.rs:19:42
139+
| ------------------------------------------------- inside `DANGLING` at $DIR/offset_ub.rs:18:42
140140

141141
error[E0080]: evaluation of constant value failed
142142
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -147,10 +147,10 @@ LL | unsafe { intrinsics::offset(self, count) }
147147
| pointer arithmetic failed: null pointer is not a valid pointer
148148
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
149149
|
150-
::: $DIR/offset_ub.rs:22:50
150+
::: $DIR/offset_ub.rs:21:50
151151
|
152152
LL | pub const NULL_OFFSET_ZERO: *const u8 = unsafe { ptr::null::<u8>().offset(0) };
153-
| --------------------------- inside `NULL_OFFSET_ZERO` at $DIR/offset_ub.rs:22:50
153+
| --------------------------- inside `NULL_OFFSET_ZERO` at $DIR/offset_ub.rs:21:50
154154

155155
error[E0080]: evaluation of constant value failed
156156
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -161,10 +161,10 @@ LL | unsafe { intrinsics::offset(self, count) }
161161
| pointer arithmetic failed: 0x7f..f is not a valid pointer
162162
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
163163
|
164-
::: $DIR/offset_ub.rs:25:47
164+
::: $DIR/offset_ub.rs:24:47
165165
|
166166
LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) };
167-
| -------------------------------------------- inside `UNDERFLOW_ABS` at $DIR/offset_ub.rs:25:47
167+
| -------------------------------------------- inside `UNDERFLOW_ABS` at $DIR/offset_ub.rs:24:47
168168

169169
error: aborting due to 12 previous errors
170170

‎src/test/ui/consts/ptr_comparisons.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#![feature(
88
core_intrinsics,
99
const_raw_ptr_comparison,
10-
const_ptr_offset,
1110
)]
1211

1312
const FOO: &usize = &42;

‎src/test/ui/consts/ptr_comparisons.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ LL | unsafe { intrinsics::offset(self, count) }
77
| pointer arithmetic failed: alloc3 has size $WORD, so pointer to $TWO_WORDS bytes starting at offset 0 is out-of-bounds
88
| inside `ptr::const_ptr::<impl *const usize>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
99
|
10-
::: $DIR/ptr_comparisons.rs:59:34
10+
::: $DIR/ptr_comparisons.rs:58:34
1111
|
1212
LL | const _: *const usize = unsafe { (FOO as *const usize).offset(2) };
13-
| ------------------------------- inside `_` at $DIR/ptr_comparisons.rs:59:34
13+
| ------------------------------- inside `_` at $DIR/ptr_comparisons.rs:58:34
1414

1515
error[E0080]: evaluation of constant value failed
16-
--> $DIR/ptr_comparisons.rs:62:33
16+
--> $DIR/ptr_comparisons.rs:61:33
1717
|
1818
LL | unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 1000]))[999]) };
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: alloc3 has size $WORD, so pointer to 1000 bytes starting at offset 0 is out-of-bounds
2020

2121
error: any use of this value will cause an error
22-
--> $DIR/ptr_comparisons.rs:66:27
22+
--> $DIR/ptr_comparisons.rs:65:27
2323
|
2424
LL | const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 };
2525
| --------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
@@ -31,7 +31,7 @@ LL | const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) +
3131
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
3232

3333
error: any use of this value will cause an error
34-
--> $DIR/ptr_comparisons.rs:71:27
34+
--> $DIR/ptr_comparisons.rs:70:27
3535
|
3636
LL | const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 };
3737
| --------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---

0 commit comments

Comments
 (0)
Please sign in to comment.