]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/offset_from_ub.stderr
Rollup merge of #85937 - m-ou-se:macro-ref-suggestions, r=estebank
[rust.git] / src / test / ui / consts / offset_from_ub.stderr
1 error: any use of this value will cause an error
2   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
3    |
4 LL |           unsafe { intrinsics::ptr_offset_from(self, origin) }
5    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6    |                    |
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
10    | 
11   ::: $DIR/offset_from_ub.rs:10: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    = 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>
25
26 error: any use of this value will cause an error
27   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
28    |
29 LL |           unsafe { intrinsics::ptr_offset_from(self, origin) }
30    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31    |                    |
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
35    | 
36   ::: $DIR/offset_from_ub.rs:20:1
37    |
38 LL | / pub const NOT_PTR: usize = {
39 LL | |
40 LL | |     unsafe { (42 as *const u8).offset_from(&5u8) as usize }
41 LL | | };
42    | |__-
43    |
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>
46
47 error: any use of this value will cause an error
48   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
49    |
50 LL |           unsafe { intrinsics::ptr_offset_from(self, origin) }
51    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
52    |                    |
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
56    | 
57   ::: $DIR/offset_from_ub.rs:25:1
58    |
59 LL | / pub const NOT_MULTIPLE_OF_SIZE: isize = {
60 LL | |
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) }
65 LL | | };
66    | |__-
67    |
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>
70
71 error: any use of this value will cause an error
72   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
73    |
74 LL |           unsafe { intrinsics::ptr_offset_from(self, origin) }
75    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76    |                    |
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
80    | 
81   ::: $DIR/offset_from_ub.rs:33:1
82    |
83 LL | / pub const OFFSET_FROM_NULL: isize = {
84 LL | |
85 LL | |     let ptr = 0 as *const u8;
86 LL | |     unsafe { ptr.offset_from(ptr) }
87 LL | | };
88    | |__-
89    |
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>
92
93 error: any use of this value will cause an error
94   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
95    |
96 LL |           unsafe { intrinsics::ptr_offset_from(self, origin) }
97    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
98    |                    |
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
102    | 
103   ::: $DIR/offset_from_ub.rs:39:1
104    |
105 LL | / pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC
106 LL | |
107 LL | |     let ptr1 = 8 as *const u8;
108 LL | |     let ptr2 = 16 as *const u8;
109 LL | |     unsafe { ptr2.offset_from(ptr1) }
110 LL | | };
111    | |__-
112    |
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>
115
116 error: aborting due to 5 previous errors
117