11error[E0080]: evaluation of constant value failed
2- --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
3- |
4- LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
5- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6- | |
7- | ptr_offset_from cannot compute offset of pointers into different allocations.
8- | inside `ptr::const_ptr::<impl *const Struct>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
9- |
10- ::: $DIR/offset_from_ub.rs:15:27
2+ --> $DIR/offset_from_ub.rs:18:27
113 |
12- LL | let offset = unsafe { field_ptr.offset_from( base_ptr) };
13- | ------------------------------- inside `DIFFERENT_ALLOC` at $DIR/offset_from_ub.rs:15:27
4+ LL | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) };
5+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from cannot compute offset of pointers into different allocations.
146
157error: any use of this value will cause an error
168 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -20,12 +12,11 @@ LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
2012 | |
2113 | unable to turn bytes into a pointer
2214 | inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
23- | inside `NOT_PTR` at $DIR/offset_from_ub.rs:21 :14
15+ | inside `NOT_PTR` at $DIR/offset_from_ub.rs:24 :14
2416 |
25- ::: $DIR/offset_from_ub.rs:19 :1
17+ ::: $DIR/offset_from_ub.rs:23 :1
2618 |
2719LL | / pub const NOT_PTR: usize = {
28- LL | |
2920LL | | unsafe { (42 as *const u8).offset_from(&5u8) as usize }
3021LL | | };
3122 | |__-
@@ -35,50 +26,26 @@ LL | | };
3526 = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
3627
3728error[E0080]: evaluation of constant value failed
38- --> $SRC_DIR/core/src/ptr/const_ptr .rs:LL:COL
29+ --> $DIR/offset_from_ub .rs:31:14
3930 |
40- LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
41- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42- | |
43- | exact_div: 1_isize cannot be divided by 2_isize without remainder
44- | inside `ptr::const_ptr::<impl *const u16>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
45- |
46- ::: $DIR/offset_from_ub.rs:28:14
47- |
48- LL | unsafe { field_ptr.offset_from(base_ptr as *const u16) }
49- | --------------------------------------------- inside `NOT_MULTIPLE_OF_SIZE` at $DIR/offset_from_ub.rs:28:14
31+ LL | unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) }
32+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 1_isize cannot be divided by 2_isize without remainder
5033
5134error[E0080]: evaluation of constant value failed
52- --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
53- |
54- LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
55- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
56- | |
57- | null pointer is not a valid pointer for this operation
58- | inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
59- |
60- ::: $DIR/offset_from_ub.rs:33:14
35+ --> $DIR/offset_from_ub.rs:37:14
6136 |
62- LL | unsafe { ptr.offset_from( ptr) }
63- | -------------------- inside `OFFSET_FROM_NULL` at $DIR/offset_from_ub.rs:33:14
37+ LL | unsafe { ptr_offset_from(ptr, ptr) }
38+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ null pointer is not a valid pointer for this operation
6439
6540error: any use of this value will cause an error
66- --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
67- |
68- LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
69- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
70- | |
71- | unable to turn bytes into a pointer
72- | inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
73- | inside `DIFFERENT_INT` at $DIR/offset_from_ub.rs:40:14
74- |
75- ::: $DIR/offset_from_ub.rs:36:1
41+ --> $DIR/offset_from_ub.rs:44:14
7642 |
7743LL | / pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC
78- LL | |
7944LL | | let ptr1 = 8 as *const u8;
8045LL | | let ptr2 = 16 as *const u8;
81- LL | | unsafe { ptr2.offset_from(ptr1) }
46+ LL | | unsafe { ptr_offset_from(ptr2, ptr1) }
47+ | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn bytes into a pointer
48+ LL | |
8249LL | | };
8350 | |__-
8451 |
0 commit comments