diff options
| author | bors <bors@rust-lang.org> | 2020-04-10 19:28:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-04-10 19:28:38 +0000 |
| commit | 14061868b3960d8a68a079bd276dde85936970ac (patch) | |
| tree | e0f2e6b8e28e84d0096de33ea663ec0b9700550b /src/liballoc | |
| parent | 9682f0e14db95076454559a24c26287bcad57955 (diff) | |
| parent | 178aa6ae9e1d6673b7e52df64c60c22c36a7ae57 (diff) | |
| download | rust-14061868b3960d8a68a079bd276dde85936970ac.tar.gz rust-14061868b3960d8a68a079bd276dde85936970ac.zip | |
Auto merge of #70994 - Centril:rollup-lftv0a3, r=Centril
Rollup of 9 pull requests Successful merges: - #69745 (Use `PredicateObligation`s instead of `Predicate`s) - #70938 (Add ThreadSanitizer test case) - #70973 (Use forward traversal for unconditional recursion lint) - #70978 (compiletest: let config flags overwrite -A unused) - #70979 (Follow up on BTreeMap comments) - #70981 (Rearrange BTreeMap::into_iter to match range_mut.) - #70985 (Clean up E0512 explanation) - #70988 (Setup the `@rustbot prioritize` command) - #70991 (fix rustc-dev-guide's url in src/librustc_codegen_ssa) Failed merges: r? @ghost
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/collections/btree/map.rs | 28 | ||||
| -rw-r--r-- | src/liballoc/collections/btree/node.rs | 4 |
2 files changed, 15 insertions, 17 deletions
diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index fc7e91ce47b..38fa3d73624 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -1544,19 +1544,19 @@ impl<K, V> IntoIterator for BTreeMap<K, V> { type IntoIter = IntoIter<K, V>; fn into_iter(self) -> IntoIter<K, V> { - let me = ManuallyDrop::new(self); - if me.root.is_none() { - return IntoIter { front: None, back: None, length: 0 }; - } - - let root1 = unsafe { unwrap_unchecked(ptr::read(&me.root)).into_ref() }; - let root2 = unsafe { unwrap_unchecked(ptr::read(&me.root)).into_ref() }; - let len = me.length; - - IntoIter { - front: Some(root1.first_leaf_edge()), - back: Some(root2.last_leaf_edge()), - length: len, + let mut me = ManuallyDrop::new(self); + if let Some(root) = me.root.as_mut() { + let root1 = unsafe { ptr::read(root).into_ref() }; + let root2 = unsafe { ptr::read(root).into_ref() }; + let len = me.length; + + IntoIter { + front: Some(root1.first_leaf_edge()), + back: Some(root2.last_leaf_edge()), + length: len, + } + } else { + IntoIter { front: None, back: None, length: 0 } } } } @@ -2771,8 +2771,6 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInter pos.next_unchecked(); } } - - // This internal node might be underfull, but only if it's the root. break; } } diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index bc4e2711670..84d34db2d45 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -161,7 +161,7 @@ impl<K, V> Root<K, V> { NodeRef { height: self.height, node: self.node.as_ptr(), - root: self as *const _ as *mut _, + root: ptr::null(), _marker: PhantomData, } } @@ -179,7 +179,7 @@ impl<K, V> Root<K, V> { NodeRef { height: self.height, node: self.node.as_ptr(), - root: ptr::null_mut(), // FIXME: Is there anything better to do here? + root: ptr::null(), _marker: PhantomData, } } |
