]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr
Rollup merge of #101655 - dns2utf8:box_docs, r=dtolnay
[rust.git] / src / test / ui / consts / const-eval / ub-wide-ptr.64bit.stderr
1 error[E0080]: it is undefined behavior to use this value
2   --> $DIR/ub-wide-ptr.rs:36:1
3    |
4 LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
5    | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
6    |
7    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
8    = note: the raw bytes of the constant (size: 16, align: 8) {
9                ╾───────allocN────────╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
10            }
11
12 error[E0080]: it is undefined behavior to use this value
13   --> $DIR/ub-wide-ptr.rs:38:1
14    |
15 LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },);
16    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object
17    |
18    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
19    = note: the raw bytes of the constant (size: 16, align: 8) {
20                ╾───────allocN───────╼ ff ff ff ff ff ff ff ff │ ╾──────╼........
21            }
22
23 error[E0080]: evaluation of constant value failed
24   --> $DIR/ub-wide-ptr.rs:41:1
25    |
26 LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) };
27    | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
28    |
29    = help: this code performed an operation that depends on the underlying bytes representing a pointer
30    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
31
32 error[E0080]: evaluation of constant value failed
33   --> $DIR/ub-wide-ptr.rs:44:1
34    |
35 LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) };
36    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
37    |
38    = help: this code performed an operation that depends on the underlying bytes representing a pointer
39    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
40
41 error[E0080]: it is undefined behavior to use this value
42   --> $DIR/ub-wide-ptr.rs:46:1
43    |
44 LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) };
45    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
46    |
47    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
48    = note: the raw bytes of the constant (size: 16, align: 8) {
49                ╾───────allocN───────╼ ff ff ff ff ff ff ff ff │ ╾──────╼........
50            }
51
52 error[E0080]: it is undefined behavior to use this value
53   --> $DIR/ub-wide-ptr.rs:50:1
54    |
55 LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
56    | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized data in `str`
57    |
58    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
59    = note: the raw bytes of the constant (size: 16, align: 8) {
60                ╾───────allocN───────╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
61            }
62
63 error[E0080]: it is undefined behavior to use this value
64   --> $DIR/ub-wide-ptr.rs:53:1
65    |
66 LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
67    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered uninitialized data in `str`
68    |
69    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
70    = note: the raw bytes of the constant (size: 16, align: 8) {
71                ╾───────allocN───────╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
72            }
73
74 error[E0080]: evaluation of constant value failed
75   --> $DIR/ub-wide-ptr.rs:60:1
76    |
77 LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe {
78    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
79
80 error[E0080]: it is undefined behavior to use this value
81   --> $DIR/ub-wide-ptr.rs:67:1
82    |
83 LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
84    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
85    |
86    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
87    = note: the raw bytes of the constant (size: 16, align: 8) {
88                ╾───────allocN───────╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
89            }
90
91 error[E0080]: it is undefined behavior to use this value
92   --> $DIR/ub-wide-ptr.rs:70:1
93    |
94 LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) };
95    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
96    |
97    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
98    = note: the raw bytes of the constant (size: 16, align: 8) {
99                ╾───────allocN───────╼ ff ff ff ff ff ff ff 7f │ ╾──────╼........
100            }
101
102 error[E0080]: evaluation of constant value failed
103   --> $DIR/ub-wide-ptr.rs:73:1
104    |
105 LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) };
106    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
107    |
108    = help: this code performed an operation that depends on the underlying bytes representing a pointer
109    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
110
111 error[E0080]: it is undefined behavior to use this value
112   --> $DIR/ub-wide-ptr.rs:76:1
113    |
114 LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) };
115    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation)
116    |
117    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
118    = note: the raw bytes of the constant (size: 16, align: 8) {
119                ╾───────allocN───────╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
120            }
121
122 error[E0080]: evaluation of constant value failed
123   --> $DIR/ub-wide-ptr.rs:79:1
124    |
125 LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) };
126    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
127    |
128    = help: this code performed an operation that depends on the underlying bytes representing a pointer
129    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
130
131 error[E0080]: it is undefined behavior to use this value
132   --> $DIR/ub-wide-ptr.rs:83:1
133    |
134 LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
135    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean
136    |
137    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
138    = note: the raw bytes of the constant (size: 8, align: 8) {
139                ╾───────allocN───────╼                         │ ╾──────╼
140            }
141
142 note: erroneous constant used
143   --> $DIR/ub-wide-ptr.rs:83:40
144    |
145 LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
146    |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
147
148 error[E0080]: it is undefined behavior to use this value
149   --> $DIR/ub-wide-ptr.rs:90:1
150    |
151 LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
152    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean
153    |
154    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
155    = note: the raw bytes of the constant (size: 8, align: 8) {
156                ╾──────allocN───────╼                         │ ╾──────╼
157            }
158
159 note: erroneous constant used
160   --> $DIR/ub-wide-ptr.rs:90:42
161    |
162 LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
163    |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
164
165 error[E0080]: it is undefined behavior to use this value
166   --> $DIR/ub-wide-ptr.rs:94:1
167    |
168 LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
169    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean
170    |
171    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
172    = note: the raw bytes of the constant (size: 8, align: 8) {
173                ╾──────allocN───────╼                         │ ╾──────╼
174            }
175
176 note: erroneous constant used
177   --> $DIR/ub-wide-ptr.rs:94:42
178    |
179 LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
180    |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
181
182 error[E0080]: evaluation of constant value failed
183   --> $DIR/ub-wide-ptr.rs:102:1
184    |
185 LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe {
186    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
187
188 error[E0080]: it is undefined behavior to use this value
189   --> $DIR/ub-wide-ptr.rs:111:1
190    |
191 LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
192    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer
193    |
194    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
195    = note: the raw bytes of the constant (size: 16, align: 8) {
196                ╾──────allocN───────╼ ╾──────allocN───────╼ │ ╾──────╼╾──────╼
197            }
198
199 error[E0080]: it is undefined behavior to use this value
200   --> $DIR/ub-wide-ptr.rs:115:1
201    |
202 LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
203    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer
204    |
205    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
206    = note: the raw bytes of the constant (size: 16, align: 8) {
207                ╾──────allocN───────╼ ╾──────allocN───────╼ │ ╾──────╼╾──────╼
208            }
209
210 error[E0080]: it is undefined behavior to use this value
211   --> $DIR/ub-wide-ptr.rs:119:1
212    |
213 LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
214    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer
215    |
216    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
217    = note: the raw bytes of the constant (size: 16, align: 8) {
218                ╾──────allocN───────╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........
219            }
220
221 error[E0080]: evaluation of constant value failed
222   --> $DIR/ub-wide-ptr.rs:122:57
223    |
224 LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) };
225    |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable
226
227 error[E0080]: evaluation of constant value failed
228   --> $DIR/ub-wide-ptr.rs:125:57
229    |
230 LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) };
231    |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable
232
233 error[E0080]: evaluation of constant value failed
234   --> $DIR/ub-wide-ptr.rs:128:56
235    |
236 LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) };
237    |                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable
238
239 error[E0080]: it is undefined behavior to use this value
240   --> $DIR/ub-wide-ptr.rs:131:1
241    |
242 LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
243    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer
244    |
245    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
246    = note: the raw bytes of the constant (size: 16, align: 8) {
247                ╾──────allocN───────╼ ╾──────allocN───────╼ │ ╾──────╼╾──────╼
248            }
249
250 error[E0080]: it is undefined behavior to use this value
251   --> $DIR/ub-wide-ptr.rs:136:1
252    |
253 LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
254    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean
255    |
256    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
257    = note: the raw bytes of the constant (size: 16, align: 8) {
258                ╾──────allocN───────╼ ╾──────allocN───────╼ │ ╾──────╼╾──────╼
259            }
260
261 error[E0080]: it is undefined behavior to use this value
262   --> $DIR/ub-wide-ptr.rs:141:1
263    |
264 LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
265    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer
266    |
267    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
268    = note: the raw bytes of the constant (size: 16, align: 8) {
269                ╾──────allocN───────╼ 00 00 00 00 00 00 00 00 │ ╾──────╼........
270            }
271
272 error[E0080]: it is undefined behavior to use this value
273   --> $DIR/ub-wide-ptr.rs:143:1
274    |
275 LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
276    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered allocN, but expected a vtable pointer
277    |
278    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
279    = note: the raw bytes of the constant (size: 16, align: 8) {
280                ╾──────allocN───────╼ ╾──────allocN───────╼ │ ╾──────╼╾──────╼
281            }
282
283 error[E0080]: could not evaluate static initializer
284   --> $DIR/ub-wide-ptr.rs:149:5
285    |
286 LL |     mem::transmute::<_, &dyn Trait>((&92u8, 0usize))
287    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance)
288
289 error[E0080]: could not evaluate static initializer
290   --> $DIR/ub-wide-ptr.rs:153:5
291    |
292 LL |     mem::transmute::<_, &dyn Trait>((&92u8, &3u64))
293    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable
294
295 error: aborting due to 29 previous errors
296
297 For more information about this error, try `rustc --explain E0080`.