fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #67350 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum73528e339aa

1.40.0
2.0 KiB61 linesraw
1error: any use of this value will cause an error
2  --> $SRC_DIR/libcore/ptr/mod.rs:LL:COL
3   |
4LL |           intrinsics::ptr_offset_from(self, origin)
5   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6   |           |
7   |           ptr_offset_from cannot compute offset of pointers into different allocations.
8   |           inside call to `std::ptr::<impl *const Struct>::offset_from` at $DIR/offset_from_ub.rs:19:27
9   | 
10  ::: $DIR/offset_from_ub.rs:13:1
11   |
12LL | / pub const DIFFERENT_ALLOC: usize = {
13LL | |
14LL | |     let uninit = std::mem::MaybeUninit::<Struct>::uninit();
15LL | |     let base_ptr: *const Struct = &uninit as *const _ as *const Struct;
16...  |
17LL | |     offset as usize
18LL | | };
19   | |__-
20   |
21   = note: `#[deny(const_err)]` on by default
22
23error: any use of this value will cause an error
24  --> $SRC_DIR/libcore/ptr/mod.rs:LL:COL
25   |
26LL |           intrinsics::ptr_offset_from(self, origin)
27   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28   |           |
29   |           a memory access tried to interpret some bytes as a pointer
30   |           inside call to `std::ptr::<impl *const u8>::offset_from` at $DIR/offset_from_ub.rs:25:14
31   | 
32  ::: $DIR/offset_from_ub.rs:23:1
33   |
34LL | / pub const NOT_PTR: usize = {
35LL | |
36LL | |     unsafe { (42 as *const u8).offset_from(&5u8) as usize }
37LL | | };
38   | |__-
39
40error: any use of this value will cause an error
41  --> $SRC_DIR/libcore/ptr/mod.rs:LL:COL
42   |
43LL |           intrinsics::ptr_offset_from(self, origin)
44   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45   |           |
46   |           exact_div: 1 cannot be divided by 2 without remainder
47   |           inside call to `std::ptr::<impl *const u16>::offset_from` at $DIR/offset_from_ub.rs:33:27
48   | 
49  ::: $DIR/offset_from_ub.rs:28:1
50   |
51LL | / pub const NOT_MULTIPLE_OF_SIZE: usize = {
52LL | |
53LL | |     let data = [5u8, 6, 7];
54LL | |     let base_ptr = data.as_ptr();
55...  |
56LL | |     offset as usize
57LL | | };
58   | |__-
59
60error: aborting due to 3 previous errors
61