-error: any use of this value will cause an error
- --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
- |
-LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- | |
- | ptr_offset_from cannot compute offset of pointers into different allocations.
- | inside `ptr::const_ptr::<impl *const Struct>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
- | inside `DIFFERENT_ALLOC` at $DIR/offset_from_ub.rs:16:27
- |
- ::: $DIR/offset_from_ub.rs:10:1
+error[E0080]: evaluation of constant value failed
+ --> $DIR/offset_from_ub.rs:18:27
|
-LL | / pub const DIFFERENT_ALLOC: usize = {
-LL | |
-LL | | let uninit = std::mem::MaybeUninit::<Struct>::uninit();
-LL | | let base_ptr: *const Struct = &uninit as *const _ as *const Struct;
-... |
-LL | | offset as usize
-LL | | };
- | |__-
- |
- = 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 | 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:22: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:20:1
- |
-LL | / pub const NOT_PTR: usize = {
-LL | |
-LL | | unsafe { (42 as *const u8).offset_from(&5u8) as usize }
-LL | | };
- | |__-
+ ::: $DIR/offset_from_ub.rs:24:14
|
- = 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: any use of this value will cause an error
- --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
- |
-LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- | |
- | exact_div: 1_isize cannot be divided by 2_isize without remainder
- | inside `ptr::const_ptr::<impl *const u16>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
- | inside `NOT_MULTIPLE_OF_SIZE` at $DIR/offset_from_ub.rs:30:14
- |
- ::: $DIR/offset_from_ub.rs:25:1
- |
-LL | / pub const NOT_MULTIPLE_OF_SIZE: isize = {
-LL | |
-LL | | let data = [5u8, 6, 7];
-LL | | let base_ptr = data.as_ptr();
-LL | | let field_ptr = &data[1] as *const u8 as *const u16;
-LL | | unsafe { field_ptr.offset_from(base_ptr as *const u16) }
-LL | | };
- | |__-
+error[E0080]: evaluation of constant value failed
+ --> $DIR/offset_from_ub.rs:31:14
|
- = 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(field_ptr, base_ptr as *const u16) }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 1_isize cannot be divided by 2_isize without remainder
-error: any use of this value will cause an error
- --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
- |
-LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- | |
- | null pointer is not a valid pointer for this operation
- | inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
- | inside `OFFSET_FROM_NULL` at $DIR/offset_from_ub.rs:36:14
- |
- ::: $DIR/offset_from_ub.rs:33:1
- |
-LL | / pub const OFFSET_FROM_NULL: isize = {
-LL | |
-LL | | let ptr = 0 as *const u8;
-LL | | unsafe { ptr.offset_from(ptr) }
-LL | | };
- | |__-
+error[E0080]: evaluation of constant value failed
+ --> $DIR/offset_from_ub.rs:37:14
|
- = 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(ptr, ptr) }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ null pointer is not a valid pointer for this operation
-error: any use of this value will cause an error
- --> $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 `DIFFERENT_INT` at $DIR/offset_from_ub.rs:43:14
- |
- ::: $DIR/offset_from_ub.rs:39:1
- |
-LL | / pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC
-LL | |
-LL | | let ptr1 = 8 as *const u8;
-LL | | let ptr2 = 16 as *const u8;
-LL | | unsafe { ptr2.offset_from(ptr1) }
-LL | | };
- | |__-
+error[E0080]: evaluation of constant value failed
+ --> $DIR/offset_from_ub.rs:44:14
|
- = 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
+For more information about this error, try `rustc --explain E0080`.