LL | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from cannot compute offset of pointers into different allocations.
-error: any use of this value will cause an error
+error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
-LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- | |
- | unable to turn bytes into a pointer
- | inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
- | inside `NOT_PTR` at $DIR/offset_from_ub.rs:24:14
+LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | |
+ | 0x2a is not a valid pointer
+ | inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
- ::: $DIR/offset_from_ub.rs:23:1
- |
-LL | / pub const NOT_PTR: usize = {
-LL | | unsafe { (42 as *const u8).offset_from(&5u8) as usize }
-LL | | };
- | |__-
+ ::: $DIR/offset_from_ub.rs:24:14
|
- = note: `#[deny(const_err)]` on by default
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
+LL | unsafe { (42 as *const u8).offset_from(&5u8) as usize }
+ | ----------------------------------- inside `NOT_PTR` at $DIR/offset_from_ub.rs:24:14
error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:31:14
LL | unsafe { ptr_offset_from(ptr, ptr) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^ null pointer is not a valid pointer for this operation
-error: any use of this value will cause an error
+error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:44:14
|
-LL | / pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC
-LL | | let ptr1 = 8 as *const u8;
-LL | | let ptr2 = 16 as *const u8;
-LL | | unsafe { ptr_offset_from(ptr2, ptr1) }
- | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn bytes into a pointer
-LL | |
-LL | | };
- | |__-
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
+LL | unsafe { ptr_offset_from(ptr2, ptr1) }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0x10 is not a valid pointer
error: aborting due to 5 previous errors