use a const to hack around promotion limitations
This commit is contained in:
parent
ad261f6852
commit
4b47e78a16
3 changed files with 10 additions and 2 deletions
|
@ -85,6 +85,7 @@
|
||||||
#![feature(fmt_internals)]
|
#![feature(fmt_internals)]
|
||||||
#![feature(fn_traits)]
|
#![feature(fn_traits)]
|
||||||
#![feature(fundamental)]
|
#![feature(fundamental)]
|
||||||
|
#![feature(internal_uninit_const)]
|
||||||
#![feature(lang_items)]
|
#![feature(lang_items)]
|
||||||
#![feature(libc)]
|
#![feature(libc)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
|
|
|
@ -653,7 +653,7 @@ macro_rules! uninit_array {
|
||||||
#[cfg(not(bootstrap))]
|
#[cfg(not(bootstrap))]
|
||||||
macro_rules! uninit_array {
|
macro_rules! uninit_array {
|
||||||
($t:ty; $size:expr) => (
|
($t:ty; $size:expr) => (
|
||||||
[MaybeUninit::<$t>::uninit(); $size]
|
[MaybeUninit::<$t>::UNINIT; $size]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,11 +248,18 @@ impl<T> MaybeUninit<T> {
|
||||||
/// [type]: union.MaybeUninit.html
|
/// [type]: union.MaybeUninit.html
|
||||||
#[stable(feature = "maybe_uninit", since = "1.36.0")]
|
#[stable(feature = "maybe_uninit", since = "1.36.0")]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[rustc_promotable]
|
|
||||||
pub const fn uninit() -> MaybeUninit<T> {
|
pub const fn uninit() -> MaybeUninit<T> {
|
||||||
MaybeUninit { uninit: () }
|
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
|
/// 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
|
/// filled with `0` bytes. It depends on `T` whether that already makes for
|
||||||
/// proper initialization. For example, `MaybeUninit<usize>::zeroed()` is initialized,
|
/// proper initialization. For example, `MaybeUninit<usize>::zeroed()` is initialized,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue