1 error: any use of this value will cause an error
2 --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
4 LL | intrinsics::ptr_offset_from(self, origin)
5 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7 | ptr_offset_from cannot compute offset of pointers into different allocations.
8 | inside `std::ptr::const_ptr::<impl *const Struct>::offset_from` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
9 | inside `DIFFERENT_ALLOC` at $DIR/offset_from_ub.rs:17:27
11 ::: $DIR/offset_from_ub.rs:11: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
24 error: any use of this value will cause an error
25 --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
27 LL | intrinsics::ptr_offset_from(self, origin)
28 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30 | unable to turn bytes into a pointer
31 | inside `std::ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
32 | inside `NOT_PTR` at $DIR/offset_from_ub.rs:23:14
34 ::: $DIR/offset_from_ub.rs:21:1
36 LL | / pub const NOT_PTR: usize = {
38 LL | | unsafe { (42 as *const u8).offset_from(&5u8) as usize }
42 error: any use of this value will cause an error
43 --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
45 LL | intrinsics::ptr_offset_from(self, origin)
46 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48 | exact_div: 1isize cannot be divided by 2isize without remainder
49 | inside `std::ptr::const_ptr::<impl *const u16>::offset_from` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
50 | inside `NOT_MULTIPLE_OF_SIZE` at $DIR/offset_from_ub.rs:31:14
52 ::: $DIR/offset_from_ub.rs:26:1
54 LL | / pub const NOT_MULTIPLE_OF_SIZE: isize = {
56 LL | | let data = [5u8, 6, 7];
57 LL | | let base_ptr = data.as_ptr();
58 LL | | let field_ptr = &data[1] as *const u8 as *const u16;
59 LL | | unsafe { field_ptr.offset_from(base_ptr as *const u16) }
63 error: any use of this value will cause an error
64 --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
66 LL | intrinsics::ptr_offset_from(self, origin)
67 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
69 | invalid use of NULL pointer
70 | inside `std::ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
71 | inside `OFFSET_FROM_NULL` at $DIR/offset_from_ub.rs:37:14
73 ::: $DIR/offset_from_ub.rs:34:1
75 LL | / pub const OFFSET_FROM_NULL: isize = {
77 LL | | let ptr = 0 as *const u8;
78 LL | | unsafe { ptr.offset_from(ptr) }
82 error: any use of this value will cause an error
83 --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
85 LL | intrinsics::ptr_offset_from(self, origin)
86 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
88 | unable to turn bytes into a pointer
89 | inside `std::ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
90 | inside `DIFFERENT_INT` at $DIR/offset_from_ub.rs:44:14
92 ::: $DIR/offset_from_ub.rs:40:1
94 LL | / pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC
96 LL | | let ptr1 = 8 as *const u8;
97 LL | | let ptr2 = 16 as *const u8;
98 LL | | unsafe { ptr2.offset_from(ptr1) }
102 error: aborting due to 5 previous errors