diff options
| author | Ralf Jung <post@ralfj.de> | 2019-07-21 12:02:28 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-07-21 12:28:18 +0200 |
| commit | 4b47e78a16524ed4878bfffaaf60c32bb18d88ae (patch) | |
| tree | fbf72e621143ec1934805855dcd5255353b4a027 /src/libcore | |
| parent | ad261f6852c928d3ce0a6dd34ec6c3a38792e4de (diff) | |
| download | rust-4b47e78a16524ed4878bfffaaf60c32bb18d88ae.tar.gz rust-4b47e78a16524ed4878bfffaaf60c32bb18d88ae.zip | |
use a const to hack around promotion limitations
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/macros.rs | 2 | ||||
| -rw-r--r-- | src/libcore/mem/maybe_uninit.rs | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 9855c5fb9c3..296bb43f9fa 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -653,7 +653,7 @@ macro_rules! uninit_array { #[cfg(not(bootstrap))] macro_rules! uninit_array { ($t:ty; $size:expr) => ( - [MaybeUninit::<$t>::uninit(); $size] + [MaybeUninit::<$t>::UNINIT; $size] ); } diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs index 1c69e7f90f6..9ce89f9669d 100644 --- a/src/libcore/mem/maybe_uninit.rs +++ b/src/libcore/mem/maybe_uninit.rs @@ -248,11 +248,18 @@ impl<T> MaybeUninit<T> { /// [type]: union.MaybeUninit.html #[stable(feature = "maybe_uninit", since = "1.36.0")] #[inline(always)] - #[rustc_promotable] pub const fn uninit() -> MaybeUninit<T> { MaybeUninit { uninit: () } } + /// A promotable constant, equivalent to `uninit()`. + #[unstable( + feature = "internal_uninit_const", + issue = "0", + reason = "hack to work around promotability", + )] + pub const UNINIT: Self = Self::uninit(); + /// Creates a new `MaybeUninit<T>` in an uninitialized state, with the memory being /// filled with `0` bytes. It depends on `T` whether that already makes for /// proper initialization. For example, `MaybeUninit<usize>::zeroed()` is initialized, |
