fork/rust

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

borsAuto merge of #72883 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum49cae55760d

1.44.0
3.7 KiB103 linesraw
1error: any use of this value will cause an error
2  --> $SRC_DIR/libcore/ptr/const_ptr.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 `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
10   | 
11  ::: $DIR/offset_from_ub.rs:11:1
12   |
13LL | / pub const DIFFERENT_ALLOC: usize = {
14LL | |
15LL | |     let uninit = std::mem::MaybeUninit::<Struct>::uninit();
16LL | |     let base_ptr: *const Struct = &uninit as *const _ as *const Struct;
17...  |
18LL | |     offset as usize
19LL | | };
20   | |__-
21   |
22   = note: `#[deny(const_err)]` on by default
23
24error: any use of this value will cause an error
25  --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
26   |
27LL |           intrinsics::ptr_offset_from(self, origin)
28   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29   |           |
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
33   | 
34  ::: $DIR/offset_from_ub.rs:21:1
35   |
36LL | / pub const NOT_PTR: usize = {
37LL | |
38LL | |     unsafe { (42 as *const u8).offset_from(&5u8) as usize }
39LL | | };
40   | |__-
41
42error: any use of this value will cause an error
43  --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
44   |
45LL |           intrinsics::ptr_offset_from(self, origin)
46   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47   |           |
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
51   | 
52  ::: $DIR/offset_from_ub.rs:26:1
53   |
54LL | / pub const NOT_MULTIPLE_OF_SIZE: isize = {
55LL | |
56LL | |     let data = [5u8, 6, 7];
57LL | |     let base_ptr = data.as_ptr();
58LL | |     let field_ptr = &data[1] as *const u8 as *const u16;
59LL | |     unsafe { field_ptr.offset_from(base_ptr as *const u16) }
60LL | | };
61   | |__-
62
63error: any use of this value will cause an error
64  --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
65   |
66LL |           intrinsics::ptr_offset_from(self, origin)
67   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
68   |           |
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
72   | 
73  ::: $DIR/offset_from_ub.rs:34:1
74   |
75LL | / pub const OFFSET_FROM_NULL: isize = {
76LL | |
77LL | |     let ptr = 0 as *const u8;
78LL | |     unsafe { ptr.offset_from(ptr) }
79LL | | };
80   | |__-
81
82error: any use of this value will cause an error
83  --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
84   |
85LL |           intrinsics::ptr_offset_from(self, origin)
86   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87   |           |
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
91   | 
92  ::: $DIR/offset_from_ub.rs:40:1
93   |
94LL | / pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC
95LL | |
96LL | |     let ptr1 = 8 as *const u8;
97LL | |     let ptr2 = 16 as *const u8;
98LL | |     unsafe { ptr2.offset_from(ptr1) }
99LL | | };
100   | |__-
101
102error: aborting due to 5 previous errors
103