1 error: any use of this value will cause an error
2 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
4 LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
5 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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 | inside `DIFFERENT_ALLOC` at $DIR/offset_from_ub.rs:16:27
11 ::: $DIR/offset_from_ub.rs:10:1
13 LL | / pub const DIFFERENT_ALLOC: usize = {
15 LL | | let uninit = std::mem::MaybeUninit::<Struct>::uninit();
16 LL | | let base_ptr: *const Struct = &uninit as *const _ as *const Struct;
18 LL | | offset as usize
22 = note: `#[deny(const_err)]` on by default
23 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
24 = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
26 error: any use of this value will cause an error
27 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
29 LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
30 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32 | unable to turn bytes into a pointer
33 | inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
34 | inside `NOT_PTR` at $DIR/offset_from_ub.rs:22:14
36 ::: $DIR/offset_from_ub.rs:20:1
38 LL | / pub const NOT_PTR: usize = {
40 LL | | unsafe { (42 as *const u8).offset_from(&5u8) as usize }
44 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
45 = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
47 error: any use of this value will cause an error
48 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
50 LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
51 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
53 | exact_div: 1_isize cannot be divided by 2_isize without remainder
54 | inside `ptr::const_ptr::<impl *const u16>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
55 | inside `NOT_MULTIPLE_OF_SIZE` at $DIR/offset_from_ub.rs:30:14
57 ::: $DIR/offset_from_ub.rs:25:1
59 LL | / pub const NOT_MULTIPLE_OF_SIZE: isize = {
61 LL | | let data = [5u8, 6, 7];
62 LL | | let base_ptr = data.as_ptr();
63 LL | | let field_ptr = &data[1] as *const u8 as *const u16;
64 LL | | unsafe { field_ptr.offset_from(base_ptr as *const u16) }
68 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
69 = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
71 error: any use of this value will cause an error
72 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
74 LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
75 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
77 | null pointer is not a valid pointer for this operation
78 | inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
79 | inside `OFFSET_FROM_NULL` at $DIR/offset_from_ub.rs:36:14
81 ::: $DIR/offset_from_ub.rs:33:1
83 LL | / pub const OFFSET_FROM_NULL: isize = {
85 LL | | let ptr = 0 as *const u8;
86 LL | | unsafe { ptr.offset_from(ptr) }
90 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
91 = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
93 error: any use of this value will cause an error
94 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
96 LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
97 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99 | unable to turn bytes into a pointer
100 | inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
101 | inside `DIFFERENT_INT` at $DIR/offset_from_ub.rs:43:14
103 ::: $DIR/offset_from_ub.rs:39:1
105 LL | / pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC
107 LL | | let ptr1 = 8 as *const u8;
108 LL | | let ptr2 = 16 as *const u8;
109 LL | | unsafe { ptr2.offset_from(ptr1) }
113 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
114 = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
116 error: aborting due to 5 previous errors