]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/offset_from_ub.stderr
Auto merge of #85775 - adamrk:warn-unused-target-fields, r=nagisa
[rust.git] / src / test / ui / consts / offset_from_ub.stderr
1 error[E0080]: evaluation of constant value failed
2   --> $DIR/offset_from_ub.rs:18:27
3    |
4 LL |     let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) };
5    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from cannot compute offset of pointers into different allocations.
6
7 error: any use of this value will cause an error
8   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
9    |
10 LL |           unsafe { intrinsics::ptr_offset_from(self, origin) }
11    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12    |                    |
13    |                    unable to turn bytes into a pointer
14    |                    inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
15    |                    inside `NOT_PTR` at $DIR/offset_from_ub.rs:24:14
16    | 
17   ::: $DIR/offset_from_ub.rs:23:1
18    |
19 LL | / pub const NOT_PTR: usize = {
20 LL | |     unsafe { (42 as *const u8).offset_from(&5u8) as usize }
21 LL | | };
22    | |__-
23    |
24    = note: `#[deny(const_err)]` on by default
25    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
26    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
27
28 error[E0080]: evaluation of constant value failed
29   --> $DIR/offset_from_ub.rs:31:14
30    |
31 LL |     unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) }
32    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 1_isize cannot be divided by 2_isize without remainder
33
34 error[E0080]: evaluation of constant value failed
35   --> $DIR/offset_from_ub.rs:37:14
36    |
37 LL |     unsafe { ptr_offset_from(ptr, ptr) }
38    |              ^^^^^^^^^^^^^^^^^^^^^^^^^ null pointer is not a valid pointer for this operation
39
40 error: any use of this value will cause an error
41   --> $DIR/offset_from_ub.rs:44:14
42    |
43 LL | / pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC
44 LL | |     let ptr1 = 8 as *const u8;
45 LL | |     let ptr2 = 16 as *const u8;
46 LL | |     unsafe { ptr_offset_from(ptr2, ptr1) }
47    | |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn bytes into a pointer
48 LL | |
49 LL | | };
50    | |__-
51    |
52    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
53    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
54
55 error: aborting due to 5 previous errors
56
57 For more information about this error, try `rustc --explain E0080`.