From 96a2e65449eebd797cf44b1c89a4936ae7063749 Mon Sep 17 00:00:00 2001 From: 5225225 <5225225@mailbox.org> Date: Thu, 8 Sep 2022 10:24:44 +0100 Subject: [PATCH] Add more tests, add docs for is_mem_uninit field --- compiler/rustc_lint/src/builtin.rs | 9 +- .../mem-uninitialized-future-compat.rs | 39 ++ .../mem-uninitialized-future-compat.stderr | 362 ++++++++++++++++-- 3 files changed, 380 insertions(+), 30 deletions(-) diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index a4261048d8d03..aaaa90ab7bf73 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -2366,7 +2366,14 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue { #[derive(Debug, Copy, Clone, PartialEq)] enum InitKind { Zeroed, - Uninit { is_mem_uninit: bool }, + /// `is_mem_uninit` is true *only* if this is a call to `mem::uninitialized()`, not if + /// this is a `MaybeUninit::uninit().assume_init()`. + /// + /// This lets us avoid duplicate errors being shown, for code that matches the + /// mem_uninitialized FCW. + Uninit { + is_mem_uninit: bool, + }, } impl InitKind { diff --git a/src/test/ui/intrinsics/mem-uninitialized-future-compat.rs b/src/test/ui/intrinsics/mem-uninitialized-future-compat.rs index abfc2271ac158..bd0ac6c3ee062 100644 --- a/src/test/ui/intrinsics/mem-uninitialized-future-compat.rs +++ b/src/test/ui/intrinsics/mem-uninitialized-future-compat.rs @@ -9,6 +9,19 @@ struct UninitStruct { b: char, } +enum OneVariant { + Hello, +} + +enum TwoVariant { + Hello, + Goodbye, +} + +enum OneVariantWith { + Hello(T), +} + unsafe fn unknown_type() { std::mem::uninitialized::(); //~^ ERROR the type `T` is generic, and might not permit being left uninitialized @@ -22,6 +35,12 @@ unsafe fn unknown_type() { std::mem::uninitialized::<[UninitStruct; N]>(); //~^ ERROR the type `[UninitStruct; N]` is generic, and might not permit being left uninitialized + std::mem::uninitialized::>(); + //~^ ERROR the type `std::result::Result` does not permit being left uninitialized + + std::mem::uninitialized::>(); + //~^ ERROR the type `OneVariantWith` is generic, and might not permit being left uninitialized + std::mem::uninitialized::<[T; 0]>(); std::mem::uninitialized::<[char; 0]>(); } @@ -58,10 +77,30 @@ fn main() { std::mem::uninitialized::<(u32, char)>(); //~^ ERROR the type `(u32, char)` does not permit being left uninitialized + std::mem::uninitialized::(); + //~^ ERROR the type `TwoVariant` does not permit being left uninitialized + + std::mem::uninitialized::>(); + //~^ ERROR the type `std::result::Result` does not permit being left uninitialized + + std::mem::uninitialized::>(); + //~^ ERROR the type `std::result::Result` does not permit being left uninitialized + + std::mem::uninitialized::>(); + //~^ ERROR the type `std::option::Option` does not permit being left uninitialized + + std::mem::uninitialized::>(); + //~^ ERROR the type `OneVariantWith` does not permit being left uninitialized + + std::mem::uninitialized::>(); + //~^ ERROR the type `OneVariantWith` does not permit being left uninitialized + std::mem::uninitialized::>>(); std::mem::uninitialized::(); std::mem::uninitialized::(); std::mem::uninitialized::<*const u8>(); std::mem::uninitialized::<[u8; 64]>(); + std::mem::uninitialized::(); + std::mem::uninitialized::>(); } } diff --git a/src/test/ui/intrinsics/mem-uninitialized-future-compat.stderr b/src/test/ui/intrinsics/mem-uninitialized-future-compat.stderr index 8111b24a46699..11f9cd44de58c 100644 --- a/src/test/ui/intrinsics/mem-uninitialized-future-compat.stderr +++ b/src/test/ui/intrinsics/mem-uninitialized-future-compat.stderr @@ -1,5 +1,5 @@ error: the type `T` is generic, and might not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:13:5 + --> $DIR/mem-uninitialized-future-compat.rs:26:5 | LL | std::mem::uninitialized::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | #![deny(mem_uninitialized)] = note: type might not be allowed to be left uninitialized error: the type `[T; N]` is generic, and might not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:16:5 + --> $DIR/mem-uninitialized-future-compat.rs:29:5 | LL | std::mem::uninitialized::<[T; N]>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | std::mem::uninitialized::<[T; N]>(); = note: type might not be allowed to be left uninitialized error: the type `[char; N]` is generic, and might not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:19:5 + --> $DIR/mem-uninitialized-future-compat.rs:32:5 | LL | std::mem::uninitialized::<[char; N]>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | std::mem::uninitialized::<[char; N]>(); = note: characters must be a valid Unicode codepoint error: the type `[UninitStruct; N]` is generic, and might not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:22:5 + --> $DIR/mem-uninitialized-future-compat.rs:35:5 | LL | std::mem::uninitialized::<[UninitStruct; N]>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -55,8 +55,40 @@ note: characters must be a valid Unicode codepoint (in this struct field) LL | b: char, | ^^^^^^^ +error: the type `std::result::Result` does not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:38:5 + | +LL | std::mem::uninitialized::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | + = note: for more information, see FIXME: fill this in +note: enums have to be initialized to a variant + --> $SRC_DIR/core/src/result.rs:LL:COL + | +LL | pub enum Result { + | ^^^^^^^^^^^^^^^^^^^^^ + +error: the type `OneVariantWith` is generic, and might not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:41:5 + | +LL | std::mem::uninitialized::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | + = note: for more information, see FIXME: fill this in +note: type might not be allowed to be left uninitialized (in this enum field) + --> $DIR/mem-uninitialized-future-compat.rs:22:11 + | +LL | Hello(T), + | ^ + error: the type `&u32` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:31:9 + --> $DIR/mem-uninitialized-future-compat.rs:50:9 | LL | std::mem::uninitialized::<&'static u32>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +100,7 @@ LL | std::mem::uninitialized::<&'static u32>(); = note: references must be non-null error: the type `std::boxed::Box` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:34:9 + --> $DIR/mem-uninitialized-future-compat.rs:53:9 | LL | std::mem::uninitialized::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -80,7 +112,7 @@ LL | std::mem::uninitialized::>(); = note: `Box` must be non-null error: the type `fn()` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:37:9 + --> $DIR/mem-uninitialized-future-compat.rs:56:9 | LL | std::mem::uninitialized::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -92,7 +124,7 @@ LL | std::mem::uninitialized::(); = note: function pointers must be non-null error: the type `!` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:40:9 + --> $DIR/mem-uninitialized-future-compat.rs:59:9 | LL | std::mem::uninitialized::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -104,7 +136,7 @@ LL | std::mem::uninitialized::(); = note: the `!` type has no valid value error: the type `*mut dyn std::io::Write` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:43:9 + --> $DIR/mem-uninitialized-future-compat.rs:62:9 | LL | std::mem::uninitialized::<*mut dyn std::io::Write>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -116,7 +148,7 @@ LL | std::mem::uninitialized::<*mut dyn std::io::Write>(); = note: the vtable of a wide raw pointer must be non-null error: the type `bool` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:46:9 + --> $DIR/mem-uninitialized-future-compat.rs:65:9 | LL | std::mem::uninitialized::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -128,7 +160,7 @@ LL | std::mem::uninitialized::(); = note: booleans must be either `true` or `false` error: the type `char` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:49:9 + --> $DIR/mem-uninitialized-future-compat.rs:68:9 | LL | std::mem::uninitialized::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -140,7 +172,7 @@ LL | std::mem::uninitialized::(); = note: characters must be a valid Unicode codepoint error: the type `UninitStruct` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:52:9 + --> $DIR/mem-uninitialized-future-compat.rs:71:9 | LL | std::mem::uninitialized::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -156,7 +188,7 @@ LL | b: char, | ^^^^^^^ error: the type `[UninitStruct; 16]` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:55:9 + --> $DIR/mem-uninitialized-future-compat.rs:74:9 | LL | std::mem::uninitialized::<[UninitStruct; 16]>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -172,7 +204,7 @@ LL | b: char, | ^^^^^^^ error: the type `(u32, char)` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:58:9 + --> $DIR/mem-uninitialized-future-compat.rs:77:9 | LL | std::mem::uninitialized::<(u32, char)>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -183,11 +215,107 @@ LL | std::mem::uninitialized::<(u32, char)>(); = note: for more information, see FIXME: fill this in = note: characters must be a valid Unicode codepoint -error: aborting due to 14 previous errors +error: the type `TwoVariant` does not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:80:9 + | +LL | std::mem::uninitialized::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | + = note: for more information, see FIXME: fill this in +note: enums have to be initialized to a variant + --> $DIR/mem-uninitialized-future-compat.rs:16:1 + | +LL | enum TwoVariant { + | ^^^^^^^^^^^^^^^ + +error: the type `std::result::Result` does not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:83:9 + | +LL | std::mem::uninitialized::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | + = note: for more information, see FIXME: fill this in +note: enums have to be initialized to a variant + --> $SRC_DIR/core/src/result.rs:LL:COL + | +LL | pub enum Result { + | ^^^^^^^^^^^^^^^^^^^^^ + +error: the type `std::result::Result` does not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:86:9 + | +LL | std::mem::uninitialized::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | + = note: for more information, see FIXME: fill this in +note: enums have to be initialized to a variant + --> $SRC_DIR/core/src/result.rs:LL:COL + | +LL | pub enum Result { + | ^^^^^^^^^^^^^^^^^^^^^ + +error: the type `std::option::Option` does not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:89:9 + | +LL | std::mem::uninitialized::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | + = note: for more information, see FIXME: fill this in +note: enums have to be initialized to a variant + --> $SRC_DIR/core/src/option.rs:LL:COL + | +LL | pub enum Option { + | ^^^^^^^^^^^^^^^^^^ + +error: the type `OneVariantWith` does not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:92:9 + | +LL | std::mem::uninitialized::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | + = note: for more information, see FIXME: fill this in +note: characters must be a valid Unicode codepoint (in this enum field) + --> $DIR/mem-uninitialized-future-compat.rs:22:11 + | +LL | Hello(T), + | ^ + +error: the type `OneVariantWith` does not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:95:9 + | +LL | std::mem::uninitialized::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | + = note: for more information, see FIXME: fill this in +note: the `!` type has no valid value (in this enum field) + --> $DIR/mem-uninitialized-future-compat.rs:22:11 + | +LL | Hello(T), + | ^ + +error: aborting due to 22 previous errors Future incompatibility report: Future breakage diagnostic: error: the type `T` is generic, and might not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:13:5 + --> $DIR/mem-uninitialized-future-compat.rs:26:5 | LL | std::mem::uninitialized::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -205,7 +333,7 @@ LL | #![deny(mem_uninitialized)] Future breakage diagnostic: error: the type `[T; N]` is generic, and might not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:16:5 + --> $DIR/mem-uninitialized-future-compat.rs:29:5 | LL | std::mem::uninitialized::<[T; N]>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -223,7 +351,7 @@ LL | #![deny(mem_uninitialized)] Future breakage diagnostic: error: the type `[char; N]` is generic, and might not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:19:5 + --> $DIR/mem-uninitialized-future-compat.rs:32:5 | LL | std::mem::uninitialized::<[char; N]>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -241,7 +369,7 @@ LL | #![deny(mem_uninitialized)] Future breakage diagnostic: error: the type `[UninitStruct; N]` is generic, and might not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:22:5 + --> $DIR/mem-uninitialized-future-compat.rs:35:5 | LL | std::mem::uninitialized::<[UninitStruct; N]>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -261,9 +389,53 @@ note: characters must be a valid Unicode codepoint (in this struct field) LL | b: char, | ^^^^^^^ +Future breakage diagnostic: +error: the type `std::result::Result` does not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:38:5 + | +LL | std::mem::uninitialized::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | +note: the lint level is defined here + --> $DIR/mem-uninitialized-future-compat.rs:2:9 + | +LL | #![deny(mem_uninitialized)] + | ^^^^^^^^^^^^^^^^^ + = note: for more information, see FIXME: fill this in +note: enums have to be initialized to a variant + --> $SRC_DIR/core/src/result.rs:LL:COL + | +LL | pub enum Result { + | ^^^^^^^^^^^^^^^^^^^^^ + +Future breakage diagnostic: +error: the type `OneVariantWith` is generic, and might not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:41:5 + | +LL | std::mem::uninitialized::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | +note: the lint level is defined here + --> $DIR/mem-uninitialized-future-compat.rs:2:9 + | +LL | #![deny(mem_uninitialized)] + | ^^^^^^^^^^^^^^^^^ + = note: for more information, see FIXME: fill this in +note: type might not be allowed to be left uninitialized (in this enum field) + --> $DIR/mem-uninitialized-future-compat.rs:22:11 + | +LL | Hello(T), + | ^ + Future breakage diagnostic: error: the type `&u32` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:31:9 + --> $DIR/mem-uninitialized-future-compat.rs:50:9 | LL | std::mem::uninitialized::<&'static u32>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -281,7 +453,7 @@ LL | #![deny(mem_uninitialized)] Future breakage diagnostic: error: the type `std::boxed::Box` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:34:9 + --> $DIR/mem-uninitialized-future-compat.rs:53:9 | LL | std::mem::uninitialized::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -299,7 +471,7 @@ LL | #![deny(mem_uninitialized)] Future breakage diagnostic: error: the type `fn()` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:37:9 + --> $DIR/mem-uninitialized-future-compat.rs:56:9 | LL | std::mem::uninitialized::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -317,7 +489,7 @@ LL | #![deny(mem_uninitialized)] Future breakage diagnostic: error: the type `!` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:40:9 + --> $DIR/mem-uninitialized-future-compat.rs:59:9 | LL | std::mem::uninitialized::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -335,7 +507,7 @@ LL | #![deny(mem_uninitialized)] Future breakage diagnostic: error: the type `*mut dyn std::io::Write` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:43:9 + --> $DIR/mem-uninitialized-future-compat.rs:62:9 | LL | std::mem::uninitialized::<*mut dyn std::io::Write>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -353,7 +525,7 @@ LL | #![deny(mem_uninitialized)] Future breakage diagnostic: error: the type `bool` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:46:9 + --> $DIR/mem-uninitialized-future-compat.rs:65:9 | LL | std::mem::uninitialized::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -371,7 +543,7 @@ LL | #![deny(mem_uninitialized)] Future breakage diagnostic: error: the type `char` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:49:9 + --> $DIR/mem-uninitialized-future-compat.rs:68:9 | LL | std::mem::uninitialized::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -389,7 +561,7 @@ LL | #![deny(mem_uninitialized)] Future breakage diagnostic: error: the type `UninitStruct` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:52:9 + --> $DIR/mem-uninitialized-future-compat.rs:71:9 | LL | std::mem::uninitialized::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -411,7 +583,7 @@ LL | b: char, Future breakage diagnostic: error: the type `[UninitStruct; 16]` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:55:9 + --> $DIR/mem-uninitialized-future-compat.rs:74:9 | LL | std::mem::uninitialized::<[UninitStruct; 16]>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -433,7 +605,7 @@ LL | b: char, Future breakage diagnostic: error: the type `(u32, char)` does not permit being left uninitialized - --> $DIR/mem-uninitialized-future-compat.rs:58:9 + --> $DIR/mem-uninitialized-future-compat.rs:77:9 | LL | std::mem::uninitialized::<(u32, char)>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -449,3 +621,135 @@ LL | #![deny(mem_uninitialized)] = note: for more information, see FIXME: fill this in = note: characters must be a valid Unicode codepoint +Future breakage diagnostic: +error: the type `TwoVariant` does not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:80:9 + | +LL | std::mem::uninitialized::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | +note: the lint level is defined here + --> $DIR/mem-uninitialized-future-compat.rs:2:9 + | +LL | #![deny(mem_uninitialized)] + | ^^^^^^^^^^^^^^^^^ + = note: for more information, see FIXME: fill this in +note: enums have to be initialized to a variant + --> $DIR/mem-uninitialized-future-compat.rs:16:1 + | +LL | enum TwoVariant { + | ^^^^^^^^^^^^^^^ + +Future breakage diagnostic: +error: the type `std::result::Result` does not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:83:9 + | +LL | std::mem::uninitialized::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | +note: the lint level is defined here + --> $DIR/mem-uninitialized-future-compat.rs:2:9 + | +LL | #![deny(mem_uninitialized)] + | ^^^^^^^^^^^^^^^^^ + = note: for more information, see FIXME: fill this in +note: enums have to be initialized to a variant + --> $SRC_DIR/core/src/result.rs:LL:COL + | +LL | pub enum Result { + | ^^^^^^^^^^^^^^^^^^^^^ + +Future breakage diagnostic: +error: the type `std::result::Result` does not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:86:9 + | +LL | std::mem::uninitialized::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | +note: the lint level is defined here + --> $DIR/mem-uninitialized-future-compat.rs:2:9 + | +LL | #![deny(mem_uninitialized)] + | ^^^^^^^^^^^^^^^^^ + = note: for more information, see FIXME: fill this in +note: enums have to be initialized to a variant + --> $SRC_DIR/core/src/result.rs:LL:COL + | +LL | pub enum Result { + | ^^^^^^^^^^^^^^^^^^^^^ + +Future breakage diagnostic: +error: the type `std::option::Option` does not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:89:9 + | +LL | std::mem::uninitialized::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | +note: the lint level is defined here + --> $DIR/mem-uninitialized-future-compat.rs:2:9 + | +LL | #![deny(mem_uninitialized)] + | ^^^^^^^^^^^^^^^^^ + = note: for more information, see FIXME: fill this in +note: enums have to be initialized to a variant + --> $SRC_DIR/core/src/option.rs:LL:COL + | +LL | pub enum Option { + | ^^^^^^^^^^^^^^^^^^ + +Future breakage diagnostic: +error: the type `OneVariantWith` does not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:92:9 + | +LL | std::mem::uninitialized::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | +note: the lint level is defined here + --> $DIR/mem-uninitialized-future-compat.rs:2:9 + | +LL | #![deny(mem_uninitialized)] + | ^^^^^^^^^^^^^^^^^ + = note: for more information, see FIXME: fill this in +note: characters must be a valid Unicode codepoint (in this enum field) + --> $DIR/mem-uninitialized-future-compat.rs:22:11 + | +LL | Hello(T), + | ^ + +Future breakage diagnostic: +error: the type `OneVariantWith` does not permit being left uninitialized + --> $DIR/mem-uninitialized-future-compat.rs:95:9 + | +LL | std::mem::uninitialized::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | +note: the lint level is defined here + --> $DIR/mem-uninitialized-future-compat.rs:2:9 + | +LL | #![deny(mem_uninitialized)] + | ^^^^^^^^^^^^^^^^^ + = note: for more information, see FIXME: fill this in +note: the `!` type has no valid value (in this enum field) + --> $DIR/mem-uninitialized-future-compat.rs:22:11 + | +LL | Hello(T), + | ^ +