about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_data_structures/src')
-rw-r--r--compiler/rustc_data_structures/src/lib.rs1
-rw-r--r--compiler/rustc_data_structures/src/sharded.rs20
2 files changed, 1 insertions, 20 deletions
diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs
index dd6a17b92ae..b1f04bfbf0a 100644
--- a/compiler/rustc_data_structures/src/lib.rs
+++ b/compiler/rustc_data_structures/src/lib.rs
@@ -18,7 +18,6 @@
 #![feature(extend_one)]
 #![feature(hash_raw_entry)]
 #![feature(in_band_lifetimes)]
-#![feature(iter_map_while)]
 #![feature(maybe_uninit_uninit_array)]
 #![feature(min_specialization)]
 #![feature(never_type)]
diff --git a/compiler/rustc_data_structures/src/sharded.rs b/compiler/rustc_data_structures/src/sharded.rs
index 14db71cb8f0..417c61242a5 100644
--- a/compiler/rustc_data_structures/src/sharded.rs
+++ b/compiler/rustc_data_structures/src/sharded.rs
@@ -1,6 +1,5 @@
 use crate::fx::{FxHashMap, FxHasher};
 use crate::sync::{Lock, LockGuard};
-use smallvec::SmallVec;
 use std::borrow::Borrow;
 use std::collections::hash_map::RawEntryMut;
 use std::hash::{Hash, Hasher};
@@ -37,24 +36,7 @@ impl<T: Default> Default for Sharded<T> {
 impl<T> Sharded<T> {
     #[inline]
     pub fn new(mut value: impl FnMut() -> T) -> Self {
-        // Create a vector of the values we want
-        let mut values: SmallVec<[_; SHARDS]> =
-            (0..SHARDS).map(|_| CacheAligned(Lock::new(value()))).collect();
-
-        // Create an uninitialized array
-        let mut shards: mem::MaybeUninit<[CacheAligned<Lock<T>>; SHARDS]> =
-            mem::MaybeUninit::uninit();
-
-        unsafe {
-            // Copy the values into our array
-            let first = shards.as_mut_ptr() as *mut CacheAligned<Lock<T>>;
-            values.as_ptr().copy_to_nonoverlapping(first, SHARDS);
-
-            // Ignore the content of the vector
-            values.set_len(0);
-
-            Sharded { shards: shards.assume_init() }
-        }
+        Sharded { shards: [(); SHARDS].map(|()| CacheAligned(Lock::new(value()))) }
     }
 
     /// The shard is selected by hashing `val` with `FxHasher`.