1 error: the type `&T` does not permit zero-initialization
2 --> $DIR/invalid_value.rs:54:32
4 LL | let _val: &'static T = mem::zeroed();
7 | this code causes undefined behavior when executed
8 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
10 = note: references must be non-null
11 note: the lint level is defined here
12 --> $DIR/invalid_value.rs:6:9
14 LL | #![deny(invalid_value)]
17 error: the type `&T` does not permit being left uninitialized
18 --> $DIR/invalid_value.rs:55:32
20 LL | let _val: &'static T = mem::uninitialized();
21 | ^^^^^^^^^^^^^^^^^^^^
23 | this code causes undefined behavior when executed
24 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
26 = note: references must be non-null
28 error: the type `Wrap<&T>` does not permit zero-initialization
29 --> $DIR/invalid_value.rs:57:38
31 LL | let _val: Wrap<&'static T> = mem::zeroed();
34 | this code causes undefined behavior when executed
35 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
37 = note: `Wrap<&T>` must be non-null
38 note: because references must be non-null (in this struct field)
39 --> $DIR/invalid_value.rs:17:18
41 LL | struct Wrap<T> { wrapped: T }
44 error: the type `Wrap<&T>` does not permit being left uninitialized
45 --> $DIR/invalid_value.rs:58:38
47 LL | let _val: Wrap<&'static T> = mem::uninitialized();
48 | ^^^^^^^^^^^^^^^^^^^^
50 | this code causes undefined behavior when executed
51 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
53 = note: `Wrap<&T>` must be non-null
54 note: because references must be non-null (in this struct field)
55 --> $DIR/invalid_value.rs:17:18
57 LL | struct Wrap<T> { wrapped: T }
60 error: the type `!` does not permit zero-initialization
61 --> $DIR/invalid_value.rs:65:23
63 LL | let _val: ! = mem::zeroed();
66 | this code causes undefined behavior when executed
67 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
69 = note: the `!` type has no valid value
71 error: the type `!` does not permit being left uninitialized
72 --> $DIR/invalid_value.rs:66:23
74 LL | let _val: ! = mem::uninitialized();
75 | ^^^^^^^^^^^^^^^^^^^^
77 | this code causes undefined behavior when executed
78 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
80 = note: the `!` type has no valid value
82 error: the type `(i32, !)` does not permit zero-initialization
83 --> $DIR/invalid_value.rs:68:30
85 LL | let _val: (i32, !) = mem::zeroed();
88 | this code causes undefined behavior when executed
89 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
91 = note: the `!` type has no valid value
93 error: the type `(i32, !)` does not permit being left uninitialized
94 --> $DIR/invalid_value.rs:69:30
96 LL | let _val: (i32, !) = mem::uninitialized();
97 | ^^^^^^^^^^^^^^^^^^^^
99 | this code causes undefined behavior when executed
100 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
102 = note: integers must be initialized
104 error: the type `Void` does not permit zero-initialization
105 --> $DIR/invalid_value.rs:71:26
107 LL | let _val: Void = mem::zeroed();
110 | this code causes undefined behavior when executed
111 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
113 note: enums with no inhabited variants have no valid value
114 --> $DIR/invalid_value.rs:12:1
119 error: the type `Void` does not permit being left uninitialized
120 --> $DIR/invalid_value.rs:72:26
122 LL | let _val: Void = mem::uninitialized();
123 | ^^^^^^^^^^^^^^^^^^^^
125 | this code causes undefined behavior when executed
126 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
128 note: enums with no inhabited variants have no valid value
129 --> $DIR/invalid_value.rs:12:1
134 error: the type `&i32` does not permit zero-initialization
135 --> $DIR/invalid_value.rs:74:34
137 LL | let _val: &'static i32 = mem::zeroed();
140 | this code causes undefined behavior when executed
141 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
143 = note: references must be non-null
145 error: the type `&i32` does not permit being left uninitialized
146 --> $DIR/invalid_value.rs:75:34
148 LL | let _val: &'static i32 = mem::uninitialized();
149 | ^^^^^^^^^^^^^^^^^^^^
151 | this code causes undefined behavior when executed
152 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
154 = note: references must be non-null
156 error: the type `Ref` does not permit zero-initialization
157 --> $DIR/invalid_value.rs:77:25
159 LL | let _val: Ref = mem::zeroed();
162 | this code causes undefined behavior when executed
163 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
165 = note: `Ref` must be non-null
166 note: because references must be non-null (in this struct field)
167 --> $DIR/invalid_value.rs:14:12
169 LL | struct Ref(&'static i32);
172 error: the type `Ref` does not permit being left uninitialized
173 --> $DIR/invalid_value.rs:78:25
175 LL | let _val: Ref = mem::uninitialized();
176 | ^^^^^^^^^^^^^^^^^^^^
178 | this code causes undefined behavior when executed
179 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
181 = note: `Ref` must be non-null
182 note: because references must be non-null (in this struct field)
183 --> $DIR/invalid_value.rs:14:12
185 LL | struct Ref(&'static i32);
188 error: the type `fn()` does not permit zero-initialization
189 --> $DIR/invalid_value.rs:80:26
191 LL | let _val: fn() = mem::zeroed();
194 | this code causes undefined behavior when executed
195 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
197 = note: function pointers must be non-null
199 error: the type `fn()` does not permit being left uninitialized
200 --> $DIR/invalid_value.rs:81:26
202 LL | let _val: fn() = mem::uninitialized();
203 | ^^^^^^^^^^^^^^^^^^^^
205 | this code causes undefined behavior when executed
206 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
208 = note: function pointers must be non-null
210 error: the type `Wrap<fn()>` does not permit zero-initialization
211 --> $DIR/invalid_value.rs:83:32
213 LL | let _val: Wrap<fn()> = mem::zeroed();
216 | this code causes undefined behavior when executed
217 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
219 = note: `Wrap<fn()>` must be non-null
220 note: because function pointers must be non-null (in this struct field)
221 --> $DIR/invalid_value.rs:17:18
223 LL | struct Wrap<T> { wrapped: T }
226 error: the type `Wrap<fn()>` does not permit being left uninitialized
227 --> $DIR/invalid_value.rs:84:32
229 LL | let _val: Wrap<fn()> = mem::uninitialized();
230 | ^^^^^^^^^^^^^^^^^^^^
232 | this code causes undefined behavior when executed
233 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
235 = note: `Wrap<fn()>` must be non-null
236 note: because function pointers must be non-null (in this struct field)
237 --> $DIR/invalid_value.rs:17:18
239 LL | struct Wrap<T> { wrapped: T }
242 error: the type `WrapEnum<fn()>` does not permit zero-initialization
243 --> $DIR/invalid_value.rs:86:36
245 LL | let _val: WrapEnum<fn()> = mem::zeroed();
248 | this code causes undefined behavior when executed
249 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
251 = note: `WrapEnum<fn()>` must be non-null
252 note: because function pointers must be non-null (in this field of the only potentially inhabited enum variant)
253 --> $DIR/invalid_value.rs:18:28
255 LL | enum WrapEnum<T> { Wrapped(T) }
258 error: the type `WrapEnum<fn()>` does not permit being left uninitialized
259 --> $DIR/invalid_value.rs:87:36
261 LL | let _val: WrapEnum<fn()> = mem::uninitialized();
262 | ^^^^^^^^^^^^^^^^^^^^
264 | this code causes undefined behavior when executed
265 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
267 = note: `WrapEnum<fn()>` must be non-null
268 note: because function pointers must be non-null (in this field of the only potentially inhabited enum variant)
269 --> $DIR/invalid_value.rs:18:28
271 LL | enum WrapEnum<T> { Wrapped(T) }
274 error: the type `Wrap<(RefPair, i32)>` does not permit zero-initialization
275 --> $DIR/invalid_value.rs:89:42
277 LL | let _val: Wrap<(RefPair, i32)> = mem::zeroed();
280 | this code causes undefined behavior when executed
281 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
283 note: `RefPair` must be non-null (in this struct field)
284 --> $DIR/invalid_value.rs:17:18
286 LL | struct Wrap<T> { wrapped: T }
288 note: because references must be non-null (in this struct field)
289 --> $DIR/invalid_value.rs:15:16
291 LL | struct RefPair((&'static i32, i32));
292 | ^^^^^^^^^^^^^^^^^^^
294 error: the type `Wrap<(RefPair, i32)>` does not permit being left uninitialized
295 --> $DIR/invalid_value.rs:90:42
297 LL | let _val: Wrap<(RefPair, i32)> = mem::uninitialized();
298 | ^^^^^^^^^^^^^^^^^^^^
300 | this code causes undefined behavior when executed
301 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
303 note: `RefPair` must be non-null (in this struct field)
304 --> $DIR/invalid_value.rs:17:18
306 LL | struct Wrap<T> { wrapped: T }
308 note: because references must be non-null (in this struct field)
309 --> $DIR/invalid_value.rs:15:16
311 LL | struct RefPair((&'static i32, i32));
312 | ^^^^^^^^^^^^^^^^^^^
314 error: the type `NonNull<i32>` does not permit zero-initialization
315 --> $DIR/invalid_value.rs:92:34
317 LL | let _val: NonNull<i32> = mem::zeroed();
320 | this code causes undefined behavior when executed
321 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
323 = note: `std::ptr::NonNull<i32>` must be non-null
325 error: the type `NonNull<i32>` does not permit being left uninitialized
326 --> $DIR/invalid_value.rs:93:34
328 LL | let _val: NonNull<i32> = mem::uninitialized();
329 | ^^^^^^^^^^^^^^^^^^^^
331 | this code causes undefined behavior when executed
332 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
334 = note: `std::ptr::NonNull<i32>` must be non-null
335 = note: raw pointers must be initialized
337 error: the type `(NonZeroU32, i32)` does not permit zero-initialization
338 --> $DIR/invalid_value.rs:95:39
340 LL | let _val: (NonZeroU32, i32) = mem::zeroed();
343 | this code causes undefined behavior when executed
344 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
346 = note: `std::num::NonZeroU32` must be non-null
348 error: the type `(NonZeroU32, i32)` does not permit being left uninitialized
349 --> $DIR/invalid_value.rs:96:39
351 LL | let _val: (NonZeroU32, i32) = mem::uninitialized();
352 | ^^^^^^^^^^^^^^^^^^^^
354 | this code causes undefined behavior when executed
355 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
357 = note: `std::num::NonZeroU32` must be non-null
358 = note: integers must be initialized
360 error: the type `*const dyn Send` does not permit zero-initialization
361 --> $DIR/invalid_value.rs:98:37
363 LL | let _val: *const dyn Send = mem::zeroed();
366 | this code causes undefined behavior when executed
367 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
369 = note: the vtable of a wide raw pointer must be non-null
371 error: the type `*const dyn Send` does not permit being left uninitialized
372 --> $DIR/invalid_value.rs:99:37
374 LL | let _val: *const dyn Send = mem::uninitialized();
375 | ^^^^^^^^^^^^^^^^^^^^
377 | this code causes undefined behavior when executed
378 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
380 = note: the vtable of a wide raw pointer must be non-null
382 error: the type `[fn(); 2]` does not permit zero-initialization
383 --> $DIR/invalid_value.rs:101:31
385 LL | let _val: [fn(); 2] = mem::zeroed();
388 | this code causes undefined behavior when executed
389 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
391 = note: function pointers must be non-null
393 error: the type `[fn(); 2]` does not permit being left uninitialized
394 --> $DIR/invalid_value.rs:102:31
396 LL | let _val: [fn(); 2] = mem::uninitialized();
397 | ^^^^^^^^^^^^^^^^^^^^
399 | this code causes undefined behavior when executed
400 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
402 = note: function pointers must be non-null
404 error: the type `TwoUninhabited` does not permit zero-initialization
405 --> $DIR/invalid_value.rs:104:36
407 LL | let _val: TwoUninhabited = mem::zeroed();
410 | this code causes undefined behavior when executed
411 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
413 note: enums with no inhabited variants have no valid value
414 --> $DIR/invalid_value.rs:42:1
416 LL | enum TwoUninhabited {
417 | ^^^^^^^^^^^^^^^^^^^
419 error: the type `TwoUninhabited` does not permit being left uninitialized
420 --> $DIR/invalid_value.rs:105:36
422 LL | let _val: TwoUninhabited = mem::uninitialized();
423 | ^^^^^^^^^^^^^^^^^^^^
425 | this code causes undefined behavior when executed
426 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
428 note: enums with no inhabited variants have no valid value
429 --> $DIR/invalid_value.rs:42:1
431 LL | enum TwoUninhabited {
432 | ^^^^^^^^^^^^^^^^^^^
434 error: the type `OneFruitNonZero` does not permit zero-initialization
435 --> $DIR/invalid_value.rs:107:37
437 LL | let _val: OneFruitNonZero = mem::zeroed();
440 | this code causes undefined behavior when executed
441 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
443 = note: `OneFruitNonZero` must be non-null
444 note: because `std::num::NonZeroU32` must be non-null (in this field of the only potentially inhabited enum variant)
445 --> $DIR/invalid_value.rs:39:12
447 LL | Banana(NonZeroU32),
450 error: the type `OneFruitNonZero` does not permit being left uninitialized
451 --> $DIR/invalid_value.rs:108:37
453 LL | let _val: OneFruitNonZero = mem::uninitialized();
454 | ^^^^^^^^^^^^^^^^^^^^
456 | this code causes undefined behavior when executed
457 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
459 = note: `OneFruitNonZero` must be non-null
460 note: because `std::num::NonZeroU32` must be non-null (in this field of the only potentially inhabited enum variant)
461 --> $DIR/invalid_value.rs:39:12
463 LL | Banana(NonZeroU32),
465 = note: integers must be initialized
467 error: the type `bool` does not permit being left uninitialized
468 --> $DIR/invalid_value.rs:112:26
470 LL | let _val: bool = mem::uninitialized();
471 | ^^^^^^^^^^^^^^^^^^^^
473 | this code causes undefined behavior when executed
474 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
476 = note: booleans must be either `true` or `false`
478 error: the type `Wrap<char>` does not permit being left uninitialized
479 --> $DIR/invalid_value.rs:115:32
481 LL | let _val: Wrap<char> = mem::uninitialized();
482 | ^^^^^^^^^^^^^^^^^^^^
484 | this code causes undefined behavior when executed
485 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
487 = note: `Wrap<char>` must be initialized inside its custom valid range
488 note: characters must be a valid Unicode codepoint (in this struct field)
489 --> $DIR/invalid_value.rs:17:18
491 LL | struct Wrap<T> { wrapped: T }
494 error: the type `NonBig` does not permit being left uninitialized
495 --> $DIR/invalid_value.rs:118:28
497 LL | let _val: NonBig = mem::uninitialized();
498 | ^^^^^^^^^^^^^^^^^^^^
500 | this code causes undefined behavior when executed
501 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
503 = note: `NonBig` must be initialized inside its custom valid range
504 note: integers must be initialized (in this struct field)
505 --> $DIR/invalid_value.rs:23:26
507 LL | pub(crate) struct NonBig(u64);
510 error: the type `Fruit` does not permit being left uninitialized
511 --> $DIR/invalid_value.rs:121:27
513 LL | let _val: Fruit = mem::uninitialized();
514 | ^^^^^^^^^^^^^^^^^^^^
516 | this code causes undefined behavior when executed
517 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
519 note: enums with multiple inhabited variants have to be initialized to a variant
520 --> $DIR/invalid_value.rs:26:1
525 error: the type `[bool; 2]` does not permit being left uninitialized
526 --> $DIR/invalid_value.rs:124:31
528 LL | let _val: [bool; 2] = mem::uninitialized();
529 | ^^^^^^^^^^^^^^^^^^^^
531 | this code causes undefined behavior when executed
532 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
534 = note: booleans must be either `true` or `false`
536 error: the type `i32` does not permit being left uninitialized
537 --> $DIR/invalid_value.rs:127:25
539 LL | let _val: i32 = mem::uninitialized();
540 | ^^^^^^^^^^^^^^^^^^^^
542 | this code causes undefined behavior when executed
543 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
545 = note: integers must be initialized
547 error: the type `f32` does not permit being left uninitialized
548 --> $DIR/invalid_value.rs:130:25
550 LL | let _val: f32 = mem::uninitialized();
551 | ^^^^^^^^^^^^^^^^^^^^
553 | this code causes undefined behavior when executed
554 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
556 = note: floats must be initialized
558 error: the type `*const ()` does not permit being left uninitialized
559 --> $DIR/invalid_value.rs:133:31
561 LL | let _val: *const () = mem::uninitialized();
562 | ^^^^^^^^^^^^^^^^^^^^
564 | this code causes undefined behavior when executed
565 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
567 = note: raw pointers must be initialized
569 error: the type `*const [()]` does not permit being left uninitialized
570 --> $DIR/invalid_value.rs:136:33
572 LL | let _val: *const [()] = mem::uninitialized();
573 | ^^^^^^^^^^^^^^^^^^^^
575 | this code causes undefined behavior when executed
576 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
578 = note: raw pointers must be initialized
580 error: the type `WrapAroundRange` does not permit being left uninitialized
581 --> $DIR/invalid_value.rs:139:37
583 LL | let _val: WrapAroundRange = mem::uninitialized();
584 | ^^^^^^^^^^^^^^^^^^^^
586 | this code causes undefined behavior when executed
587 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
589 = note: `WrapAroundRange` must be initialized inside its custom valid range
590 note: integers must be initialized (in this struct field)
591 --> $DIR/invalid_value.rs:49:35
593 LL | pub(crate) struct WrapAroundRange(u8);
596 error: the type `Result<i32, i32>` does not permit being left uninitialized
597 --> $DIR/invalid_value.rs:144:38
599 LL | let _val: Result<i32, i32> = mem::uninitialized();
600 | ^^^^^^^^^^^^^^^^^^^^
602 | this code causes undefined behavior when executed
603 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
605 note: enums with multiple inhabited variants have to be initialized to a variant
606 --> $SRC_DIR/core/src/result.rs:LL:COL
608 LL | pub enum Result<T, E> {
609 | ^^^^^^^^^^^^^^^^^^^^^
611 error: the type `&i32` does not permit zero-initialization
612 --> $DIR/invalid_value.rs:152:34
614 LL | let _val: &'static i32 = mem::transmute(0usize);
615 | ^^^^^^^^^^^^^^^^^^^^^^
617 | this code causes undefined behavior when executed
618 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
620 = note: references must be non-null
622 error: the type `&[i32]` does not permit zero-initialization
623 --> $DIR/invalid_value.rs:153:36
625 LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize));
626 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
628 | this code causes undefined behavior when executed
629 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
631 = note: references must be non-null
633 error: the type `NonZeroU32` does not permit zero-initialization
634 --> $DIR/invalid_value.rs:154:32
636 LL | let _val: NonZeroU32 = mem::transmute(0);
639 | this code causes undefined behavior when executed
640 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
642 = note: `std::num::NonZeroU32` must be non-null
644 error: the type `NonNull<i32>` does not permit zero-initialization
645 --> $DIR/invalid_value.rs:157:34
647 LL | let _val: NonNull<i32> = MaybeUninit::zeroed().assume_init();
648 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
650 | this code causes undefined behavior when executed
651 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
653 = note: `std::ptr::NonNull<i32>` must be non-null
655 error: the type `NonNull<i32>` does not permit being left uninitialized
656 --> $DIR/invalid_value.rs:158:34
658 LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init();
659 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
661 | this code causes undefined behavior when executed
662 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
664 = note: `std::ptr::NonNull<i32>` must be non-null
665 = note: raw pointers must be initialized
667 error: the type `bool` does not permit being left uninitialized
668 --> $DIR/invalid_value.rs:159:26
670 LL | let _val: bool = MaybeUninit::uninit().assume_init();
671 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
673 | this code causes undefined behavior when executed
674 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
676 = note: booleans must be either `true` or `false`
678 error: aborting due to 51 previous errors