diff options
| author | bors <bors@rust-lang.org> | 2018-10-01 14:58:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-10-01 14:58:24 +0000 |
| commit | de3d640f59c4fa4a09faf2a8d6b0a812aaa6d6cb (patch) | |
| tree | a972fbca76a07b42c194d259fb11105fe8d78726 /src/test/debuginfo | |
| parent | 6188c58a55a27efac25f6e50a8e5f18c2650b60f (diff) | |
| parent | dd65d732ed702302ac0943179cb2feec835975ee (diff) | |
| download | rust-de3d640f59c4fa4a09faf2a8d6b0a812aaa6d6cb.tar.gz rust-de3d640f59c4fa4a09faf2a8d6b0a812aaa6d6cb.zip | |
Auto merge of #54667 - RalfJung:maybe-uninit, r=pnkfelix
Panic when using mem::uninitialized or mem::zeroed on an uninhabited type All code by @japaric. This re-submits one half of https://github.com/rust-lang/rust/pull/53508. This is likely not the one that introduced the perf regression, but just to be sure I'll do a perf run anyway.
Diffstat (limited to 'src/test/debuginfo')
| -rw-r--r-- | src/test/debuginfo/nil-enum.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/test/debuginfo/nil-enum.rs b/src/test/debuginfo/nil-enum.rs index 94377421c0b..ab9c7e2dd27 100644 --- a/src/test/debuginfo/nil-enum.rs +++ b/src/test/debuginfo/nil-enum.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// NOTE Instantiating an empty enum is UB. This test may break in the future. + // LLDB can't handle zero-sized values // ignore-lldb @@ -25,8 +27,11 @@ #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] +#![feature(maybe_uninit)] #![omit_gdb_pretty_printer_section] +use std::mem::MaybeUninit; + enum ANilEnum {} enum AnotherNilEnum {} @@ -35,8 +40,8 @@ enum AnotherNilEnum {} // The error from gdbr is expected since nil enums are not supposed to exist. fn main() { unsafe { - let first: ANilEnum = ::std::mem::zeroed(); - let second: AnotherNilEnum = ::std::mem::zeroed(); + let first: ANilEnum = MaybeUninit::uninitialized().into_inner(); + let second: AnotherNilEnum = MaybeUninit::uninitialized().into_inner(); zzz(); // #break } |
