about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-10-27 08:24:54 +0000
committerbors <bors@rust-lang.org>2023-10-27 08:24:54 +0000
commit54e57e66ffb8ef4f97916d46f40ddcb464fc8be3 (patch)
tree0bcd84bc579f84cf8584d1b853dc803b20625f1e /tests
parent707d8c3f1bba10d5aaa9c8719c410711edf2e227 (diff)
parentfe97fdf782a89563308e0ea03b1840c8dbc0bd68 (diff)
downloadrust-54e57e66ffb8ef4f97916d46f40ddcb464fc8be3.tar.gz
rust-54e57e66ffb8ef4f97916d46f40ddcb464fc8be3.zip
Auto merge of #116205 - WaffleLapkin:stabilize_pointer_byte_offsets, r=dtolnay
Stabilize `[const_]pointer_byte_offsets`

Closes #96283
Awaiting FCP completion: https://github.com/rust-lang/rust/issues/96283#issuecomment-1735835331

r? libs-api
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/const-ptr/allowed_slices.rs2
-rw-r--r--tests/ui/const-ptr/forbidden_slices.rs2
-rw-r--r--tests/ui/const-ptr/forbidden_slices.stderr36
-rw-r--r--tests/ui/consts/const-eval/raw-pointer-ub.rs2
-rw-r--r--tests/ui/consts/const-eval/raw-pointer-ub.stderr10
-rw-r--r--tests/ui/consts/extra-const-ub/detect-extra-ub.rs2
-rw-r--r--tests/ui/consts/miri_unleashed/ptr_arith.rs1
-rw-r--r--tests/ui/consts/miri_unleashed/ptr_arith.stderr6
8 files changed, 27 insertions, 34 deletions
diff --git a/tests/ui/const-ptr/allowed_slices.rs b/tests/ui/const-ptr/allowed_slices.rs
index 3f19cd4d804..3561338a758 100644
--- a/tests/ui/const-ptr/allowed_slices.rs
+++ b/tests/ui/const-ptr/allowed_slices.rs
@@ -2,8 +2,6 @@
 #![feature(
     slice_from_ptr_range,
     const_slice_from_ptr_range,
-    pointer_byte_offsets,
-    const_pointer_byte_offsets
 )]
 use std::{
     mem::MaybeUninit,
diff --git a/tests/ui/const-ptr/forbidden_slices.rs b/tests/ui/const-ptr/forbidden_slices.rs
index 03d6499aefb..0374ac7f714 100644
--- a/tests/ui/const-ptr/forbidden_slices.rs
+++ b/tests/ui/const-ptr/forbidden_slices.rs
@@ -5,8 +5,6 @@
 #![feature(
     slice_from_ptr_range,
     const_slice_from_ptr_range,
-    pointer_byte_offsets,
-    const_pointer_byte_offsets
 )]
 use std::{
     mem::{size_of, MaybeUninit},
diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr
index 00230d59a37..105683940cf 100644
--- a/tests/ui/const-ptr/forbidden_slices.stderr
+++ b/tests/ui/const-ptr/forbidden_slices.stderr
@@ -1,5 +1,5 @@
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/forbidden_slices.rs:18:1
+  --> $DIR/forbidden_slices.rs:16:1
    |
 LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) };
    | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
@@ -10,7 +10,7 @@ LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) };
            }
 
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/forbidden_slices.rs:20:1
+  --> $DIR/forbidden_slices.rs:18:1
    |
 LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) };
    | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
@@ -21,7 +21,7 @@ LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) };
            }
 
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/forbidden_slices.rs:24:1
+  --> $DIR/forbidden_slices.rs:22:1
    |
 LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
    | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
@@ -32,7 +32,7 @@ LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
            }
 
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/forbidden_slices.rs:28:1
+  --> $DIR/forbidden_slices.rs:26:1
    |
 LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) };
    | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
@@ -43,7 +43,7 @@ LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }
            }
 
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/forbidden_slices.rs:30:1
+  --> $DIR/forbidden_slices.rs:28:1
    |
 LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) };
    | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
@@ -56,7 +56,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size
    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
 
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/forbidden_slices.rs:32:1
+  --> $DIR/forbidden_slices.rs:30:1
    |
 LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) };
    | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
@@ -67,7 +67,7 @@ LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4)
            }
 
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/forbidden_slices.rs:35:1
+  --> $DIR/forbidden_slices.rs:33:1
    |
 LL | pub static S7: &[u16] = unsafe {
    | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer
@@ -78,7 +78,7 @@ LL | pub static S7: &[u16] = unsafe {
            }
 
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/forbidden_slices.rs:43:1
+  --> $DIR/forbidden_slices.rs:41:1
    |
 LL | pub static S8: &[u64] = unsafe {
    | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
@@ -98,7 +98,7 @@ note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
 note: inside `from_ptr_range::<'_, u32>`
   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
 note: inside `R0`
-  --> $DIR/forbidden_slices.rs:50:34
+  --> $DIR/forbidden_slices.rs:48:34
    |
 LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -113,7 +113,7 @@ note: inside `ptr::const_ptr::<impl *const ()>::sub_ptr`
 note: inside `from_ptr_range::<'_, ()>`
   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
 note: inside `R1`
-  --> $DIR/forbidden_slices.rs:51:33
+  --> $DIR/forbidden_slices.rs:49:33
    |
 LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -127,13 +127,13 @@ error[E0080]: could not evaluate static initializer
 note: inside `ptr::const_ptr::<impl *const u32>::add`
   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
 note: inside `R2`
-  --> $DIR/forbidden_slices.rs:54:25
+  --> $DIR/forbidden_slices.rs:52:25
    |
 LL |     from_ptr_range(ptr..ptr.add(2))
    |                         ^^^^^^^^^^
 
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/forbidden_slices.rs:56:1
+  --> $DIR/forbidden_slices.rs:54:1
    |
 LL | pub static R4: &[u8] = unsafe {
    | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
@@ -144,7 +144,7 @@ LL | pub static R4: &[u8] = unsafe {
            }
 
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/forbidden_slices.rs:61:1
+  --> $DIR/forbidden_slices.rs:59:1
    |
 LL | pub static R5: &[u8] = unsafe {
    | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
@@ -157,7 +157,7 @@ LL | pub static R5: &[u8] = unsafe {
    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
 
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/forbidden_slices.rs:66:1
+  --> $DIR/forbidden_slices.rs:64:1
    |
 LL | pub static R6: &[bool] = unsafe {
    | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
@@ -168,7 +168,7 @@ LL | pub static R6: &[bool] = unsafe {
            }
 
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/forbidden_slices.rs:71:1
+  --> $DIR/forbidden_slices.rs:69:1
    |
 LL | pub static R7: &[u16] = unsafe {
    | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
@@ -186,7 +186,7 @@ error[E0080]: could not evaluate static initializer
 note: inside `ptr::const_ptr::<impl *const u64>::add`
   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
 note: inside `R8`
-  --> $DIR/forbidden_slices.rs:78:25
+  --> $DIR/forbidden_slices.rs:76:25
    |
 LL |     from_ptr_range(ptr..ptr.add(1))
    |                         ^^^^^^^^^^
@@ -201,7 +201,7 @@ note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
 note: inside `from_ptr_range::<'_, u32>`
   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
 note: inside `R9`
-  --> $DIR/forbidden_slices.rs:83:34
+  --> $DIR/forbidden_slices.rs:81:34
    |
 LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -216,7 +216,7 @@ note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
 note: inside `from_ptr_range::<'_, u32>`
   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
 note: inside `R10`
-  --> $DIR/forbidden_slices.rs:84:35
+  --> $DIR/forbidden_slices.rs:82:35
    |
 LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.rs b/tests/ui/consts/const-eval/raw-pointer-ub.rs
index 9b79a0a7d34..3341f3c78e0 100644
--- a/tests/ui/consts/const-eval/raw-pointer-ub.rs
+++ b/tests/ui/consts/const-eval/raw-pointer-ub.rs
@@ -1,5 +1,3 @@
-#![feature(const_pointer_byte_offsets)]
-#![feature(pointer_byte_offsets)]
 #![feature(const_mut_refs)]
 
 
diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.stderr b/tests/ui/consts/const-eval/raw-pointer-ub.stderr
index f644e5f8748..60fcd461cde 100644
--- a/tests/ui/consts/const-eval/raw-pointer-ub.stderr
+++ b/tests/ui/consts/const-eval/raw-pointer-ub.stderr
@@ -1,11 +1,11 @@
 error[E0080]: evaluation of constant value failed
-  --> $DIR/raw-pointer-ub.rs:9:16
+  --> $DIR/raw-pointer-ub.rs:7:16
    |
 LL |     let _val = *ptr;
    |                ^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required
 
 error[E0080]: evaluation of constant value failed
-  --> $DIR/raw-pointer-ub.rs:16:5
+  --> $DIR/raw-pointer-ub.rs:14:5
    |
 LL |     *ptr = 0;
    |     ^^^^^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required
@@ -20,19 +20,19 @@ note: inside `copy_nonoverlapping::<u32>`
 note: inside `ptr::const_ptr::<impl *const u32>::copy_to_nonoverlapping`
   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
 note: inside `MISALIGNED_COPY`
-  --> $DIR/raw-pointer-ub.rs:24:5
+  --> $DIR/raw-pointer-ub.rs:22:5
    |
 LL |     y.copy_to_nonoverlapping(&mut z, 1);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0080]: evaluation of constant value failed
-  --> $DIR/raw-pointer-ub.rs:36:16
+  --> $DIR/raw-pointer-ub.rs:34:16
    |
 LL |     let _val = (*ptr).0;
    |                ^^^^^^^^ accessing memory based on pointer with alignment 4, but alignment 16 is required
 
 error[E0080]: evaluation of constant value failed
-  --> $DIR/raw-pointer-ub.rs:43:16
+  --> $DIR/raw-pointer-ub.rs:41:16
    |
 LL |     let _val = *ptr;
    |                ^^^^ memory access failed: ALLOC0 has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
diff --git a/tests/ui/consts/extra-const-ub/detect-extra-ub.rs b/tests/ui/consts/extra-const-ub/detect-extra-ub.rs
index 15c06908447..39f918379d1 100644
--- a/tests/ui/consts/extra-const-ub/detect-extra-ub.rs
+++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.rs
@@ -1,7 +1,7 @@
 // revisions: no_flag with_flag
 // [no_flag] check-pass
 // [with_flag] compile-flags: -Zextra-const-ub-checks
-#![feature(never_type, pointer_byte_offsets)]
+#![feature(never_type)]
 
 use std::mem::transmute;
 use std::ptr::addr_of;
diff --git a/tests/ui/consts/miri_unleashed/ptr_arith.rs b/tests/ui/consts/miri_unleashed/ptr_arith.rs
index 5cda3c41152..e59c6725269 100644
--- a/tests/ui/consts/miri_unleashed/ptr_arith.rs
+++ b/tests/ui/consts/miri_unleashed/ptr_arith.rs
@@ -1,5 +1,4 @@
 // compile-flags: -Zunleash-the-miri-inside-of-you
-#![feature(core_intrinsics, pointer_byte_offsets)]
 
 // During CTFE, we prevent pointer-to-int casts.
 // Pointer comparisons are prevented in the trait system.
diff --git a/tests/ui/consts/miri_unleashed/ptr_arith.stderr b/tests/ui/consts/miri_unleashed/ptr_arith.stderr
index 25ca6bc4eaa..213966f90b8 100644
--- a/tests/ui/consts/miri_unleashed/ptr_arith.stderr
+++ b/tests/ui/consts/miri_unleashed/ptr_arith.stderr
@@ -1,11 +1,11 @@
 error[E0080]: could not evaluate static initializer
-  --> $DIR/ptr_arith.rs:8:13
+  --> $DIR/ptr_arith.rs:7:13
    |
 LL |     let x = &0 as *const _ as usize;
    |             ^^^^^^^^^^^^^^^^^^^^^^^ exposing pointers is not possible at compile-time
 
 error[E0080]: could not evaluate static initializer
-  --> $DIR/ptr_arith.rs:16:14
+  --> $DIR/ptr_arith.rs:15:14
    |
 LL |     let _v = x + 0;
    |              ^ unable to turn pointer into integer
@@ -16,7 +16,7 @@ LL |     let _v = x + 0;
 warning: skipping const checks
    |
 help: skipping check that does not even have a feature gate
-  --> $DIR/ptr_arith.rs:8:13
+  --> $DIR/ptr_arith.rs:7:13
    |
 LL |     let x = &0 as *const _ as usize;
    |             ^^^^^^^^^^^^^^^^^^^^^^^