]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/offset_from_ub.stderr
Rollup merge of #72279 - RalfJung:raw-ref-macros, r=nikomatsakis
[rust.git] / src / test / ui / consts / offset_from_ub.stderr
1 error: any use of this value will cause an error
2   --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
3    |
4 LL |           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    |
13 LL | / pub const DIFFERENT_ALLOC: usize = {
14 LL | |
15 LL | |     let uninit = std::mem::MaybeUninit::<Struct>::uninit();
16 LL | |     let base_ptr: *const Struct = &uninit as *const _ as *const Struct;
17 ...  |
18 LL | |     offset as usize
19 LL | | };
20    | |__-
21    |
22    = note: `#[deny(const_err)]` on by default
23
24 error: any use of this value will cause an error
25   --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
26    |
27 LL |           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    |
36 LL | / pub const NOT_PTR: usize = {
37 LL | |
38 LL | |     unsafe { (42 as *const u8).offset_from(&5u8) as usize }
39 LL | | };
40    | |__-
41
42 error: any use of this value will cause an error
43   --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
44    |
45 LL |           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    |
54 LL | / pub const NOT_MULTIPLE_OF_SIZE: isize = {
55 LL | |
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) }
60 LL | | };
61    | |__-
62
63 error: any use of this value will cause an error
64   --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
65    |
66 LL |           intrinsics::ptr_offset_from(self, origin)
67    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
68    |           |
69    |           inbounds test failed: 0x0 is not a valid 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    |
75 LL | / pub const OFFSET_FROM_NULL: isize = {
76 LL | |
77 LL | |     let ptr = 0 as *const u8;
78 LL | |     unsafe { ptr.offset_from(ptr) }
79 LL | | };
80    | |__-
81
82 error: any use of this value will cause an error
83   --> $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
84    |
85 LL |           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    |
94 LL | / pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC
95 LL | |
96 LL | |     let ptr1 = 8 as *const u8;
97 LL | |     let ptr2 = 16 as *const u8;
98 LL | |     unsafe { ptr2.offset_from(ptr1) }
99 LL | | };
100    | |__-
101
102 error: aborting due to 5 previous errors
103