diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-07-22 15:32:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-22 15:32:17 +0200 |
| commit | 5a20745c96c6e39fb45a9d47e350b2569ec5673b (patch) | |
| tree | 810bfac3c62b4226910fa5498a9ca9a7964116ff /src/liballoc | |
| parent | 7dafdd21b1581b1992408a0688a8566938f60587 (diff) | |
| parent | f3abbf71035e469fce6db37bdb444ce3e50e870f (diff) | |
Rollup merge of #62799 - RalfJung:uninit-array, r=Centril
use const array repeat expressions for uninit_array With a first implementation of https://github.com/rust-lang/rust/issues/49147 having landed, we can make this macro nicer and phase it out with the next bootstrap bump. However, to make this work, we have to mark `MaybeUninit::uninit()` as promotable. I do feel uneasy about promoting stuff involving uninitialized memory, but OTOH no *operation* on `MaybeUninit` is promotable, so maybe this is okay? r? @oli-obk @eddyb
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/collections/btree/node.rs | 6 | ||||
| -rw-r--r-- | src/liballoc/lib.rs | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index 7cf077d61d6..e067096f0c7 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -106,8 +106,8 @@ impl<K, V> LeafNode<K, V> { LeafNode { // As a general policy, we leave fields uninitialized if they can be, as this should // be both slightly faster and easier to track in Valgrind. - keys: uninitialized_array![_; CAPACITY], - vals: uninitialized_array![_; CAPACITY], + keys: uninit_array![_; CAPACITY], + vals: uninit_array![_; CAPACITY], parent: ptr::null(), parent_idx: MaybeUninit::uninit(), len: 0 @@ -159,7 +159,7 @@ impl<K, V> InternalNode<K, V> { unsafe fn new() -> Self { InternalNode { data: LeafNode::new(), - edges: uninitialized_array![_; 2*B], + edges: uninit_array![_; 2*B], } } } diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 2e48825e81c..dbc1f3b47c8 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -77,6 +77,7 @@ #![feature(box_syntax)] #![feature(cfg_target_has_atomic)] #![feature(coerce_unsized)] +#![cfg_attr(not(bootstrap), feature(const_in_array_repeat_expressions))] #![feature(dispatch_from_dyn)] #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] @@ -84,6 +85,7 @@ #![feature(fmt_internals)] #![feature(fn_traits)] #![feature(fundamental)] +#![feature(internal_uninit_const)] #![feature(lang_items)] #![feature(libc)] #![feature(nll)] |
