Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 11 pull requests #75690

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
e720f42
See also X-Link mem::{swap, take, replace}
Havvy Aug 2, 2020
7835c8c
docs(marker/copy): clarify that `&T` is also `Copy`
janriemer Aug 2, 2020
9b0f3d1
Fix documentation error
jack-champagne Aug 13, 2020
a876b3d
docs(marker/copy): provide example for `&T` being `Copy`
janriemer Aug 16, 2020
43dec0e
rephrase: struct -> type
janriemer Aug 16, 2020
dce8644
add back emojis that have been removed accidentally
janriemer Aug 16, 2020
9061da2
add empty line above code block
janriemer Aug 16, 2020
56daf63
docs: add `derive` for struct
janriemer Aug 16, 2020
b0eb55a
Add test demonstrating the issue.
jumbatm Aug 15, 2020
db75313
Fix stack overflow for recursive types.
jumbatm Aug 15, 2020
154b74e
Actually introduce a cycle in Reffy test.
jumbatm Aug 16, 2020
a1fa4e0
Remove unnecessary rebinding of def ids.
jumbatm Aug 16, 2020
80c2c80
Remove structural equiv check for Array const.
jumbatm Aug 16, 2020
bca48ad
Reduce indentation by replacing match arm w/ early return.
jumbatm Aug 16, 2020
6c57de1
Don't memoize seen types.
jumbatm Aug 16, 2020
7708abb
Avoid double hashset lookup.
jumbatm Aug 16, 2020
1321a2d
Also accept Refs for is_primitive_or_pointer
jumbatm Aug 16, 2020
bc15dd6
Wrap recursion in `ensure_sufficient_stack`.
jumbatm Aug 17, 2020
431a465
Move to intra doc links for keyword documentation
poliorcetics Aug 17, 2020
4f9cd74
Resolve true and false as booleans
jyn514 Aug 17, 2020
e24aa73
rewrite old test so that its attributes are consistent with what we w…
pnkfelix Jun 15, 2020
01e8e9f
When building lint specs map for a given scope, check if forbid prese…
pnkfelix Jun 15, 2020
ef03a5d
Regression test.
pnkfelix Jun 15, 2020
4ec4c4f
review suggestion: use existing defn rather than new intern call
pnkfelix Jun 30, 2020
8c4641b
BTreeMap: check some invariants, avoid recursion in depth first search
ssomers Aug 18, 2020
d9d84dc
Add doc examples count for --show-coverage
GuillaumeGomez Aug 18, 2020
f957bae
Update rustdoc-ui tests
GuillaumeGomez Aug 18, 2020
522d177
docs: add another `derive` for `Copy`able struct
Aug 18, 2020
ff73a40
Don't emit "is not a logical operator" error outside of associative e…
tgnottingham Aug 18, 2020
3e3a2c8
Switch to intra-doc links in /src/sys/unix/ext/*.rs
nixphix Aug 18, 2020
63d2e9b
resolve comments
nixphix Aug 19, 2020
fe58d49
Rollup merge of #73379 - pnkfelix:issue-70819-disallow-override-forbi…
tmandry Aug 19, 2020
4660474
Rollup merge of #75038 - rust-lang:Havvy-patch-1, r=steveklabnik
tmandry Aug 19, 2020
c3727ad
Rollup merge of #75049 - janriemer:patch-1, r=poliorcetics
tmandry Aug 19, 2020
4b29baf
Rollup merge of #75480 - ssomers:btree_check_invariant, r=Mark-Simula…
tmandry Aug 19, 2020
9b5522a
Rollup merge of #75499 - jack-champagne:jack-champagne/issue-75412, r…
tmandry Aug 19, 2020
e1f930c
Rollup merge of #75554 - jumbatm:fix-clashing-extern-decl-overflow, r…
tmandry Aug 19, 2020
9a305c0
Rollup merge of #75646 - poliorcetics:intra-links-keywords, r=jyn514
tmandry Aug 19, 2020
7c6e38f
Rollup merge of #75652 - jyn514:true-false-2, r=GuillaumeGomez
tmandry Aug 19, 2020
5eee694
Rollup merge of #75658 - tgnottingham:issue-75599, r=estebank
tmandry Aug 19, 2020
1bb849c
Rollup merge of #75665 - GuillaumeGomez:doc-examples-coverage, r=jyn514
tmandry Aug 19, 2020
fedadbc
Rollup merge of #75685 - nixphix:docs/unix-ext, r=jyn514
tmandry Aug 19, 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
35 changes: 3 additions & 32 deletions library/alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1236,10 +1236,10 @@ impl<K: Ord, V> BTreeMap<K, V> {
right_root.fix_left_border();

if left_root.height() < right_root.height() {
self.recalc_length();
self.length = left_root.node_as_ref().calc_length();
right.length = total_num - self.len();
} else {
right.recalc_length();
right.length = right_root.node_as_ref().calc_length();
self.length = total_num - right.len();
}

Expand Down Expand Up @@ -1283,42 +1283,13 @@ impl<K: Ord, V> BTreeMap<K, V> {
{
DrainFilter { pred, inner: self.drain_filter_inner() }
}

pub(super) fn drain_filter_inner(&mut self) -> DrainFilterInner<'_, K, V> {
let root_node = self.root.as_mut().map(|r| r.node_as_mut());
let front = root_node.map(|rn| rn.first_leaf_edge());
DrainFilterInner { length: &mut self.length, cur_leaf_edge: front }
}

/// Calculates the number of elements if it is incorrect.
fn recalc_length(&mut self) {
fn dfs<'a, K, V>(node: NodeRef<marker::Immut<'a>, K, V, marker::LeafOrInternal>) -> usize
where
K: 'a,
V: 'a,
{
let mut res = node.len();

if let Internal(node) = node.force() {
let mut edge = node.first_edge();
loop {
res += dfs(edge.reborrow().descend());
match edge.right_kv() {
Ok(right_kv) => {
edge = right_kv.right_edge();
}
Err(_) => {
break;
}
}
}
}

res
}

self.length = dfs(self.root.as_ref().unwrap().node_as_ref());
}

/// Creates a consuming iterator visiting all the keys, in sorted order.
/// The map cannot be used after calling this.
/// The iterator element type is `K`.
Expand Down
Loading