@@ -329,8 +329,30 @@ LL | let _val: *const dyn Send = mem::uninitialized();
329
329
|
330
330
= note: the vtable of a wide raw pointer must be non-null
331
331
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
+
332
354
error: the type `bool` does not permit being left uninitialized
333
- --> $DIR/uninitialized-zeroed.rs:86 :26
355
+ --> $DIR/uninitialized-zeroed.rs:89 :26
334
356
|
335
357
LL | let _val: bool = mem::uninitialized();
336
358
| ^^^^^^^^^^^^^^^^^^^^
@@ -341,7 +363,7 @@ LL | let _val: bool = mem::uninitialized();
341
363
= note: booleans must be either `true` or `false`
342
364
343
365
error: the type `Wrap<char>` does not permit being left uninitialized
344
- --> $DIR/uninitialized-zeroed.rs:89 :32
366
+ --> $DIR/uninitialized-zeroed.rs:92 :32
345
367
|
346
368
LL | let _val: Wrap<char> = mem::uninitialized();
347
369
| ^^^^^^^^^^^^^^^^^^^^
@@ -356,7 +378,7 @@ LL | struct Wrap<T> { wrapped: T }
356
378
| ^^^^^^^^^^
357
379
358
380
error: the type `NonBig` does not permit being left uninitialized
359
- --> $DIR/uninitialized-zeroed.rs:92 :28
381
+ --> $DIR/uninitialized-zeroed.rs:95 :28
360
382
|
361
383
LL | let _val: NonBig = mem::uninitialized();
362
384
| ^^^^^^^^^^^^^^^^^^^^
@@ -367,7 +389,7 @@ LL | let _val: NonBig = mem::uninitialized();
367
389
= note: `NonBig` must be initialized inside its custom valid range
368
390
369
391
error: the type `Fruit` does not permit being left uninitialized
370
- --> $DIR/uninitialized-zeroed.rs:95 :27
392
+ --> $DIR/uninitialized-zeroed.rs:98 :27
371
393
|
372
394
LL | let _val: Fruit = mem::uninitialized();
373
395
| ^^^^^^^^^^^^^^^^^^^^
@@ -384,8 +406,19 @@ LL | | Banana,
384
406
LL | | }
385
407
| |_^
386
408
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
+
387
420
error: the type `&i32` does not permit zero-initialization
388
- --> $DIR/uninitialized-zeroed.rs:98 :34
421
+ --> $DIR/uninitialized-zeroed.rs:104 :34
389
422
|
390
423
LL | let _val: &'static i32 = mem::transmute(0usize);
391
424
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -396,7 +429,7 @@ LL | let _val: &'static i32 = mem::transmute(0usize);
396
429
= note: references must be non-null
397
430
398
431
error: the type `&[i32]` does not permit zero-initialization
399
- --> $DIR/uninitialized-zeroed.rs:99 :36
432
+ --> $DIR/uninitialized-zeroed.rs:105 :36
400
433
|
401
434
LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize));
402
435
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -407,7 +440,7 @@ LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize));
407
440
= note: references must be non-null
408
441
409
442
error: the type `NonZeroU32` does not permit zero-initialization
410
- --> $DIR/uninitialized-zeroed.rs:100 :32
443
+ --> $DIR/uninitialized-zeroed.rs:106 :32
411
444
|
412
445
LL | let _val: NonZeroU32 = mem::transmute(0);
413
446
| ^^^^^^^^^^^^^^^^^
@@ -418,7 +451,7 @@ LL | let _val: NonZeroU32 = mem::transmute(0);
418
451
= note: `std::num::NonZeroU32` must be non-null
419
452
420
453
error: the type `NonNull<i32>` does not permit zero-initialization
421
- --> $DIR/uninitialized-zeroed.rs:103 :34
454
+ --> $DIR/uninitialized-zeroed.rs:109 :34
422
455
|
423
456
LL | let _val: NonNull<i32> = MaybeUninit::zeroed().assume_init();
424
457
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -429,7 +462,7 @@ LL | let _val: NonNull<i32> = MaybeUninit::zeroed().assume_init();
429
462
= note: `std::ptr::NonNull<i32>` must be non-null
430
463
431
464
error: the type `NonNull<i32>` does not permit being left uninitialized
432
- --> $DIR/uninitialized-zeroed.rs:104 :34
465
+ --> $DIR/uninitialized-zeroed.rs:110 :34
433
466
|
434
467
LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init();
435
468
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -440,7 +473,7 @@ LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init();
440
473
= note: `std::ptr::NonNull<i32>` must be non-null
441
474
442
475
error: the type `bool` does not permit being left uninitialized
443
- --> $DIR/uninitialized-zeroed.rs:105 :26
476
+ --> $DIR/uninitialized-zeroed.rs:111 :26
444
477
|
445
478
LL | let _val: bool = MaybeUninit::uninit().assume_init();
446
479
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -450,5 +483,5 @@ LL | let _val: bool = MaybeUninit::uninit().assume_init();
450
483
|
451
484
= note: booleans must be either `true` or `false`
452
485
453
- error: aborting due to 36 previous errors
486
+ error: aborting due to 39 previous errors
454
487
0 commit comments