Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
69ffed7
Add error explanation for E0755
GuillaumeGomez Sep 7, 2020
a06edda
Fix segfault if pthread_getattr_np fails
tavianator Sep 9, 2020
a684153
Only call pthread_attr_destroy() after getattr_np() succeeds on all l…
tavianator Sep 9, 2020
026922a
make replace_prefix only take &str as arguments
matthiaskrgr Sep 17, 2020
65edf54
Add a regression test for copy propagation miscompilation
tmiasko Sep 20, 2020
5ef1db3
Revert adding Atomic::from_mut.
m-ou-se Sep 20, 2020
d99bb9d
liballoc bench use imported path Bencher
pickfire Sep 20, 2020
37ec045
BTreeMap: extra testing unveiling mistakes in future PR
ssomers Sep 19, 2020
fc20b78
Fix typo in rustc_lexer docs
LingMan Sep 21, 2020
9172e27
Dogfood total_cmp in the test crate
est31 Sep 21, 2020
57baec7
update Miri for another bugfix
RalfJung Sep 21, 2020
670e204
Rollup merge of #76439 - GuillaumeGomez:add-error-explanation-e0755, …
RalfJung Sep 21, 2020
ae4b677
Rollup merge of #76521 - tavianator:fix-pthread-getattr-destroy, r=Am…
RalfJung Sep 21, 2020
982c4a9
Rollup merge of #76835 - matthiaskrgr:replace_prefix, r=lcnr
RalfJung Sep 21, 2020
b0c2eab
Rollup merge of #76967 - fusion-engineering-forks:revert-atomic-from-…
RalfJung Sep 21, 2020
9c14ef5
Rollup merge of #76977 - tmiasko:issue-76740, r=wesleywiser
RalfJung Sep 21, 2020
4b362bb
Rollup merge of #76981 - pickfire:patch-5, r=Mark-Simulacrum
RalfJung Sep 21, 2020
4547ebb
Rollup merge of #76983 - ssomers:btree_extra_test, r=Mark-Simulacrum
RalfJung Sep 21, 2020
48fc20c
Rollup merge of #76996 - LingMan:patch-1, r=ecstatic-morse
RalfJung Sep 21, 2020
fb3cb14
Rollup merge of #77009 - est31:dogfood_total_cmp, r=lcnr
RalfJung Sep 21, 2020
6417eb0
Rollup merge of #77012 - RalfJung:miri, r=RalfJung
RalfJung Sep 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
BTreeMap: extra testing unveiling mistakes in future PR
  • Loading branch information
ssomers committed Sep 20, 2020
commit 37ec0458507447565f3abdba0fab182c0dcd0e14
19 changes: 19 additions & 0 deletions library/alloc/src/collections/btree/map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ impl<'a, K: 'a, V: 'a> BTreeMap<K, V> {
let min_len = if is_root { 1 } else { node::MIN_LEN };
assert!(node.len() >= min_len, "{} < {}", node.len(), min_len);

for idx in 0..=node.len() {
let edge = unsafe { node::Handle::new_edge(node, idx) };
assert!(edge.descend().ascend().ok().unwrap() == edge);
}

internal_length += node.len();
}
Position::InternalKV(kv) => {
Expand Down Expand Up @@ -1846,3 +1851,17 @@ fn test_into_values() {
assert!(values.contains(&'b'));
assert!(values.contains(&'c'));
}

#[test]
fn test_insert_remove_intertwined() {
let loops = if cfg!(miri) { 100 } else { 1_000_000 };
let mut map = BTreeMap::new();
let mut i = 1;
for _ in 0..loops {
i = (i + 421) & 0xFF;
map.insert(i, i);
map.remove(&(0xFF - i));
}

map.check();
}
12 changes: 6 additions & 6 deletions library/alloc/src/collections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,8 @@ impl<'a, K, V> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {
}

impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {
/// Adds a key/value pair and an edge to go to the right of that pair to
/// the end of the node.
/// Adds a key/value pair, and an edge to go to the right of that pair,
/// to the end of the node.
pub fn push(&mut self, key: K, val: V, edge: Root<K, V>) {
assert!(edge.height == self.height - 1);

Expand All @@ -630,8 +630,8 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {
}
}

/// Adds a key/value pair and an edge to go to the left of that pair to
/// the beginning of the node.
/// Adds a key/value pair, and an edge to go to the left of that pair,
/// to the beginning of the node.
pub fn push_front(&mut self, key: K, val: V, edge: Root<K, V>) {
assert!(edge.height == self.height - 1);
assert!(self.len() < CAPACITY);
Expand Down Expand Up @@ -1152,7 +1152,7 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, mark
///
/// - The node is truncated to only contain the key/value pairs to the right of
/// this handle.
/// - The key and value pointed to by this handle and extracted.
/// - The key and value pointed to by this handle are extracted.
/// - All the key/value pairs to the right of this handle are put into a newly
/// allocated node.
pub fn split(mut self) -> (NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, K, V, Root<K, V>) {
Expand Down Expand Up @@ -1196,7 +1196,7 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
///
/// - The node is truncated to only contain the edges and key/value pairs to the
/// right of this handle.
/// - The key and value pointed to by this handle and extracted.
/// - The key and value pointed to by this handle are extracted.
/// - All the edges and key/value pairs to the right of this handle are put into
/// a newly allocated node.
pub fn split(mut self) -> (NodeRef<marker::Mut<'a>, K, V, marker::Internal>, K, V, Root<K, V>) {
Expand Down