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 10 pull requests #75683

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
43 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
3b2c0a9
Minor changes to Ipv4Addr
tesuji Aug 14, 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
a4995fc
Refactor `impl_for_type` into a separate function
jyn514 Aug 17, 2020
833bbb1
Say `tcx.lang_items()` less
jyn514 Aug 17, 2020
dae3a4f
Return all impls, not just the primary one
jyn514 Aug 17, 2020
c6ac860
impl_for_type -> PrimitiveType::impls
jyn514 Aug 17, 2020
3b1d2e3
Allow reusing the code in `collect_trait_impls`
jyn514 Aug 17, 2020
1b74f04
Use `impls` for intra doc links as well
jyn514 Aug 17, 2020
2858074
xpy fmt
jyn514 Aug 17, 2020
7be824e
Add a test
jyn514 Aug 17, 2020
38b920d
Capture output from threads spawned in tests
tmandry Aug 5, 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
9a8e3d8
Rollup merge of #75038 - rust-lang:Havvy-patch-1, r=steveklabnik
tmandry Aug 18, 2020
7b4ff26
Rollup merge of #75049 - janriemer:patch-1, r=poliorcetics
tmandry Aug 18, 2020
81f62a9
Rollup merge of #75110 - lzutao:ip-endianness, r=Mark-Simulacrum
tmandry Aug 18, 2020
ad4610d
Rollup merge of #75172 - tmandry:test-thread-capture, r=dtolnay
tmandry Aug 18, 2020
816e701
Rollup merge of #75480 - ssomers:btree_check_invariant, r=Mark-Simula…
tmandry Aug 18, 2020
bc4b517
Rollup merge of #75499 - jack-champagne:jack-champagne/issue-75412, r…
tmandry Aug 18, 2020
7e283e9
Rollup merge of #75554 - jumbatm:fix-clashing-extern-decl-overflow, r…
tmandry Aug 18, 2020
7e09c7e
Rollup merge of #75646 - poliorcetics:intra-links-keywords, r=jyn514
tmandry Aug 18, 2020
9360e87
Rollup merge of #75649 - jyn514:inherent-lang-impls, r=GuillaumeGomez
tmandry Aug 18, 2020
2a5b4b2
Rollup merge of #75665 - GuillaumeGomez:doc-examples-coverage, r=jyn514
tmandry Aug 18, 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