@@ -329,8 +329,30 @@ LL | let _val: *const dyn Send = mem::uninitialized();
329329 |
330330 = note: the vtable of a wide raw pointer must be non-null
331331
332+ error: the type `[fn(); 2]` does not permit zero-initialization
333+ --> $DIR/uninitialized-zeroed.rs:84:31
334+ |
335+ LL | let _val: [fn(); 2] = mem::zeroed();
336+ | ^^^^^^^^^^^^^
337+ | |
338+ | this code causes undefined behavior when executed
339+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
340+ |
341+ = note: function pointers must be non-null
342+
343+ error: the type `[fn(); 2]` does not permit being left uninitialized
344+ --> $DIR/uninitialized-zeroed.rs:85:31
345+ |
346+ LL | let _val: [fn(); 2] = mem::uninitialized();
347+ | ^^^^^^^^^^^^^^^^^^^^
348+ | |
349+ | this code causes undefined behavior when executed
350+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
351+ |
352+ = note: function pointers must be non-null
353+
332354error: the type `bool` does not permit being left uninitialized
333- --> $DIR/uninitialized-zeroed.rs:86 :26
355+ --> $DIR/uninitialized-zeroed.rs:89 :26
334356 |
335357LL | let _val: bool = mem::uninitialized();
336358 | ^^^^^^^^^^^^^^^^^^^^
@@ -341,7 +363,7 @@ LL | let _val: bool = mem::uninitialized();
341363 = note: booleans must be either `true` or `false`
342364
343365error: the type `Wrap<char>` does not permit being left uninitialized
344- --> $DIR/uninitialized-zeroed.rs:89 :32
366+ --> $DIR/uninitialized-zeroed.rs:92 :32
345367 |
346368LL | let _val: Wrap<char> = mem::uninitialized();
347369 | ^^^^^^^^^^^^^^^^^^^^
@@ -356,7 +378,7 @@ LL | struct Wrap<T> { wrapped: T }
356378 | ^^^^^^^^^^
357379
358380error: the type `NonBig` does not permit being left uninitialized
359- --> $DIR/uninitialized-zeroed.rs:92 :28
381+ --> $DIR/uninitialized-zeroed.rs:95 :28
360382 |
361383LL | let _val: NonBig = mem::uninitialized();
362384 | ^^^^^^^^^^^^^^^^^^^^
@@ -367,7 +389,7 @@ LL | let _val: NonBig = mem::uninitialized();
367389 = note: `NonBig` must be initialized inside its custom valid range
368390
369391error: the type `Fruit` does not permit being left uninitialized
370- --> $DIR/uninitialized-zeroed.rs:95 :27
392+ --> $DIR/uninitialized-zeroed.rs:98 :27
371393 |
372394LL | let _val: Fruit = mem::uninitialized();
373395 | ^^^^^^^^^^^^^^^^^^^^
@@ -384,8 +406,19 @@ LL | | Banana,
384406LL | | }
385407 | |_^
386408
409+ error: the type `[bool; 2]` does not permit being left uninitialized
410+ --> $DIR/uninitialized-zeroed.rs:101:31
411+ |
412+ LL | let _val: [bool; 2] = mem::uninitialized();
413+ | ^^^^^^^^^^^^^^^^^^^^
414+ | |
415+ | this code causes undefined behavior when executed
416+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
417+ |
418+ = note: booleans must be either `true` or `false`
419+
387420error: the type `&i32` does not permit zero-initialization
388- --> $DIR/uninitialized-zeroed.rs:98 :34
421+ --> $DIR/uninitialized-zeroed.rs:104 :34
389422 |
390423LL | let _val: &'static i32 = mem::transmute(0usize);
391424 | ^^^^^^^^^^^^^^^^^^^^^^
@@ -396,7 +429,7 @@ LL | let _val: &'static i32 = mem::transmute(0usize);
396429 = note: references must be non-null
397430
398431error: the type `&[i32]` does not permit zero-initialization
399- --> $DIR/uninitialized-zeroed.rs:99 :36
432+ --> $DIR/uninitialized-zeroed.rs:105 :36
400433 |
401434LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize));
402435 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -407,7 +440,7 @@ LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize));
407440 = note: references must be non-null
408441
409442error: the type `NonZeroU32` does not permit zero-initialization
410- --> $DIR/uninitialized-zeroed.rs:100 :32
443+ --> $DIR/uninitialized-zeroed.rs:106 :32
411444 |
412445LL | let _val: NonZeroU32 = mem::transmute(0);
413446 | ^^^^^^^^^^^^^^^^^
@@ -418,7 +451,7 @@ LL | let _val: NonZeroU32 = mem::transmute(0);
418451 = note: `std::num::NonZeroU32` must be non-null
419452
420453error: the type `NonNull<i32>` does not permit zero-initialization
421- --> $DIR/uninitialized-zeroed.rs:103 :34
454+ --> $DIR/uninitialized-zeroed.rs:109 :34
422455 |
423456LL | let _val: NonNull<i32> = MaybeUninit::zeroed().assume_init();
424457 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -429,7 +462,7 @@ LL | let _val: NonNull<i32> = MaybeUninit::zeroed().assume_init();
429462 = note: `std::ptr::NonNull<i32>` must be non-null
430463
431464error: the type `NonNull<i32>` does not permit being left uninitialized
432- --> $DIR/uninitialized-zeroed.rs:104 :34
465+ --> $DIR/uninitialized-zeroed.rs:110 :34
433466 |
434467LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init();
435468 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -440,7 +473,7 @@ LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init();
440473 = note: `std::ptr::NonNull<i32>` must be non-null
441474
442475error: the type `bool` does not permit being left uninitialized
443- --> $DIR/uninitialized-zeroed.rs:105 :26
476+ --> $DIR/uninitialized-zeroed.rs:111 :26
444477 |
445478LL | let _val: bool = MaybeUninit::uninit().assume_init();
446479 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -450,5 +483,5 @@ LL | let _val: bool = MaybeUninit::uninit().assume_init();
450483 |
451484 = note: booleans must be either `true` or `false`
452485
453- error: aborting due to 36 previous errors
486+ error: aborting due to 39 previous errors
454487
0 commit comments