about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorMichael Bradshaw <mjbshaw@google.com>2018-09-29 19:51:09 -0700
committerMichael Bradshaw <mjbshaw@google.com>2018-09-29 19:51:09 -0700
commit43cc32fbb2506eff0090e894c1e8a46b62a8eb0b (patch)
treeac301fe1be819c25d833880da0ab32bf550016eb /src/liballoc
parentaec5330082a0c4664abf0f6604c1b05768a90234 (diff)
parent9653f790333d1270f36f1614e85d8a7b54193e75 (diff)
downloadrust-43cc32fbb2506eff0090e894c1e8a46b62a8eb0b.tar.gz
rust-43cc32fbb2506eff0090e894c1e8a46b62a8eb0b.zip
Merge branch 'master' into drop
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/collections/btree/node.rs40
-rw-r--r--src/liballoc/lib.rs1
2 files changed, 20 insertions, 21 deletions
diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs
index c86278fc5dd..0315545262b 100644
--- a/src/liballoc/collections/btree/node.rs
+++ b/src/liballoc/collections/btree/node.rs
@@ -42,7 +42,7 @@
 //   This implies that even an empty internal node has at least one edge.
 
 use core::marker::PhantomData;
-use core::mem::{self, MaybeUninit};
+use core::mem;
 use core::ptr::{self, Unique, NonNull};
 use core::slice;
 
@@ -73,7 +73,7 @@ struct LeafNode<K, V> {
     /// This node's index into the parent node's `edges` array.
     /// `*node.parent.edges[node.parent_idx]` should be the same thing as `node`.
     /// This is only guaranteed to be initialized when `parent` is nonnull.
-    parent_idx: MaybeUninit<u16>,
+    parent_idx: u16,
 
     /// The number of keys and values this node stores.
     ///
@@ -83,8 +83,8 @@ struct LeafNode<K, V> {
 
     /// The arrays storing the actual data of the node. Only the first `len` elements of each
     /// array are initialized and valid.
-    keys: MaybeUninit<[K; CAPACITY]>,
-    vals: MaybeUninit<[V; CAPACITY]>,
+    keys: [K; CAPACITY],
+    vals: [V; CAPACITY],
 }
 
 impl<K, V> LeafNode<K, V> {
@@ -94,10 +94,10 @@ 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: MaybeUninit::uninitialized(),
-            vals: MaybeUninit::uninitialized(),
+            keys: mem::uninitialized(),
+            vals: mem::uninitialized(),
             parent: ptr::null(),
-            parent_idx: MaybeUninit::uninitialized(),
+            parent_idx: mem::uninitialized(),
             len: 0
         }
     }
@@ -115,10 +115,10 @@ unsafe impl Sync for LeafNode<(), ()> {}
 // ever take a pointer past the first key.
 static EMPTY_ROOT_NODE: LeafNode<(), ()> = LeafNode {
     parent: ptr::null(),
-    parent_idx: MaybeUninit::uninitialized(),
+    parent_idx: 0,
     len: 0,
-    keys: MaybeUninit::uninitialized(),
-    vals: MaybeUninit::uninitialized(),
+    keys: [(); CAPACITY],
+    vals: [(); CAPACITY],
 };
 
 /// The underlying representation of internal nodes. As with `LeafNode`s, these should be hidden
@@ -430,7 +430,7 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
                     root: self.root,
                     _marker: PhantomData
                 },
-                idx: unsafe { usize::from(*self.as_leaf().parent_idx.get_ref()) },
+                idx: self.as_leaf().parent_idx as usize,
                 _marker: PhantomData
             })
         } else {
@@ -567,7 +567,7 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Immut<'a>, K, V, Type> {
             // the node, which is allowed by LLVM.
             unsafe {
                 slice::from_raw_parts(
-                    self.as_leaf().keys.as_ptr() as *const K,
+                    self.as_leaf().keys.as_ptr(),
                     self.len()
                 )
             }
@@ -578,7 +578,7 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Immut<'a>, K, V, Type> {
         debug_assert!(!self.is_shared_root());
         unsafe {
             slice::from_raw_parts(
-                self.as_leaf().vals.as_ptr() as *const V,
+                self.as_leaf().vals.as_ptr(),
                 self.len()
             )
         }
@@ -605,7 +605,7 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
         } else {
             unsafe {
                 slice::from_raw_parts_mut(
-                    self.as_leaf_mut().keys.get_mut() as *mut [K] as *mut K,
+                    &mut self.as_leaf_mut().keys as *mut [K] as *mut K,
                     self.len()
                 )
             }
@@ -616,7 +616,7 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
         debug_assert!(!self.is_shared_root());
         unsafe {
             slice::from_raw_parts_mut(
-                self.as_leaf_mut().vals.get_mut() as *mut [V] as *mut V,
+                &mut self.as_leaf_mut().vals as *mut [V] as *mut V,
                 self.len()
             )
         }
@@ -1013,7 +1013,7 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, marker::
         let ptr = self.node.as_internal_mut() as *mut _;
         let mut child = self.descend();
         child.as_leaf_mut().parent = ptr;
-        child.as_leaf_mut().parent_idx.set(idx);
+        child.as_leaf_mut().parent_idx = idx;
     }
 
     /// Unsafely asserts to the compiler some static information about whether the underlying
@@ -1152,12 +1152,12 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::KV>
 
             ptr::copy_nonoverlapping(
                 self.node.keys().as_ptr().add(self.idx + 1),
-                new_node.keys.as_mut_ptr() as *mut K,
+                new_node.keys.as_mut_ptr(),
                 new_len
             );
             ptr::copy_nonoverlapping(
                 self.node.vals().as_ptr().add(self.idx + 1),
-                new_node.vals.as_mut_ptr() as *mut V,
+                new_node.vals.as_mut_ptr(),
                 new_len
             );
 
@@ -1210,12 +1210,12 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, marker::
 
             ptr::copy_nonoverlapping(
                 self.node.keys().as_ptr().add(self.idx + 1),
-                new_node.data.keys.as_mut_ptr() as *mut K,
+                new_node.data.keys.as_mut_ptr(),
                 new_len
             );
             ptr::copy_nonoverlapping(
                 self.node.vals().as_ptr().add(self.idx + 1),
-                new_node.data.vals.as_mut_ptr() as *mut V,
+                new_node.data.vals.as_mut_ptr(),
                 new_len
             );
             ptr::copy_nonoverlapping(
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index 7960936dad6..f92075cc84e 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -120,7 +120,6 @@
 #![feature(rustc_const_unstable)]
 #![feature(const_vec_new)]
 #![feature(slice_partition_dedup)]
-#![feature(maybe_uninit)]
 
 // Allow testing this library