Skip to content

Commit 4b47e78

Browse files
committed
use a const to hack around promotion limitations
1 parent ad261f6 commit 4b47e78

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/liballoc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
#![feature(fmt_internals)]
8686
#![feature(fn_traits)]
8787
#![feature(fundamental)]
88+
#![feature(internal_uninit_const)]
8889
#![feature(lang_items)]
8990
#![feature(libc)]
9091
#![feature(nll)]

src/libcore/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ macro_rules! uninit_array {
653653
#[cfg(not(bootstrap))]
654654
macro_rules! uninit_array {
655655
($t:ty; $size:expr) => (
656-
[MaybeUninit::<$t>::uninit(); $size]
656+
[MaybeUninit::<$t>::UNINIT; $size]
657657
);
658658
}
659659

src/libcore/mem/maybe_uninit.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,18 @@ impl<T> MaybeUninit<T> {
248248
/// [type]: union.MaybeUninit.html
249249
#[stable(feature = "maybe_uninit", since = "1.36.0")]
250250
#[inline(always)]
251-
#[rustc_promotable]
252251
pub const fn uninit() -> MaybeUninit<T> {
253252
MaybeUninit { uninit: () }
254253
}
255254

255+
/// A promotable constant, equivalent to `uninit()`.
256+
#[unstable(
257+
feature = "internal_uninit_const",
258+
issue = "0",
259+
reason = "hack to work around promotability",
260+
)]
261+
pub const UNINIT: Self = Self::uninit();
262+
256263
/// Creates a new `MaybeUninit<T>` in an uninitialized state, with the memory being
257264
/// filled with `0` bytes. It depends on `T` whether that already makes for
258265
/// proper initialization. For example, `MaybeUninit<usize>::zeroed()` is initialized,

0 commit comments

Comments
 (0)