Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions compiler/rustc_data_structures/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl_dyn_send!(
[std::sync::LazyLock<T, F> where T: DynSend, F: DynSend]
[std::collections::HashSet<K, S> where K: DynSend, S: DynSend]
[std::collections::HashMap<K, V, S> where K: DynSend, V: DynSend, S: DynSend]
[std::collections::BTreeMap<K, V, A> where K: DynSend, V: DynSend, A: std::alloc::Allocator + Clone + DynSend]
[std::collections::BTreeMap<K, V, A> where K: DynSend, V: DynSend, A: std::alloc::AllocatorClone + DynSend]
[Vec<T, A> where T: DynSend, A: std::alloc::Allocator + DynSend]
[Box<T, A> where T: ?Sized + DynSend, A: std::alloc::Allocator + DynSend]
[crate::sync::RwLock<T> where T: DynSend]
Expand Down Expand Up @@ -168,7 +168,7 @@ impl_dyn_sync!(
[std::sync::LazyLock<T, F> where T: DynSend + DynSync, F: DynSend]
[std::collections::HashSet<K, S> where K: DynSync, S: DynSync]
[std::collections::HashMap<K, V, S> where K: DynSync, V: DynSync, S: DynSync]
[std::collections::BTreeMap<K, V, A> where K: DynSync, V: DynSync, A: std::alloc::Allocator + Clone + DynSync]
[std::collections::BTreeMap<K, V, A> where K: DynSync, V: DynSync, A: std::alloc::AllocatorClone + DynSync]
[Vec<T, A> where T: DynSync, A: std::alloc::Allocator + DynSync]
[Box<T, A> where T: ?Sized + DynSync, A: std::alloc::Allocator + DynSync]
[crate::sync::RwLock<T> where T: DynSend + DynSync]
Expand Down
10 changes: 3 additions & 7 deletions library/alloc/src/collections/btree/append.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
use core::alloc::Allocator;
use core::alloc::AllocatorClone;

use super::node::{self, Root};

impl<K, V> Root<K, V> {
/// Pushes all key-value pairs to the end of the tree, incrementing a
/// `length` variable along the way. The latter makes it easier for the
/// caller to avoid a leak when the iterator panicks.
pub(super) fn bulk_push<I, A: Allocator + Clone>(
&mut self,
iter: I,
length: &mut usize,
alloc: A,
) where
pub(super) fn bulk_push<I, A: AllocatorClone>(&mut self, iter: I, length: &mut usize, alloc: A)
where
I: Iterator<Item = (K, V)>,
{
let mut cur_node = self.borrow_mut().last_leaf_edge().into_node();
Expand Down
23 changes: 10 additions & 13 deletions library/alloc/src/collections/btree/fix.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::alloc::Allocator;
use core::alloc::AllocatorClone;

use super::map::MIN_LEN;
use super::node::ForceResult::*;
Expand All @@ -10,7 +10,7 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
/// sibling. If successful but at the cost of shrinking the parent node,
/// returns that shrunk parent node. Returns an `Err` if the node is
/// an empty root.
fn fix_node_through_parent<A: Allocator + Clone>(
fn fix_node_through_parent<A: AllocatorClone>(
self,
alloc: A,
) -> Result<Option<NodeRef<marker::Mut<'a>, K, V, marker::Internal>>, Self> {
Expand Down Expand Up @@ -57,10 +57,7 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
///
/// This method does not expect ancestors to already be underfull upon entry
/// and panics if it encounters an empty ancestor.
pub(super) fn fix_node_and_affected_ancestors<A: Allocator + Clone>(
mut self,
alloc: A,
) -> bool {
pub(super) fn fix_node_and_affected_ancestors<A: AllocatorClone>(mut self, alloc: A) -> bool {
loop {
match self.fix_node_through_parent(alloc.clone()) {
Ok(Some(parent)) => self = parent.forget_type(),
Expand All @@ -73,7 +70,7 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {

impl<K, V> Root<K, V> {
/// Removes empty levels on the top, but keeps an empty leaf if the entire tree is empty.
pub(super) fn fix_top<A: Allocator + Clone>(&mut self, alloc: A) {
pub(super) fn fix_top<A: AllocatorClone>(&mut self, alloc: A) {
while self.height() > 0 && self.len() == 0 {
self.pop_internal_level(alloc.clone());
}
Expand All @@ -82,7 +79,7 @@ impl<K, V> Root<K, V> {
/// Stocks up or merge away any underfull nodes on the right border of the
/// tree. The other nodes, those that are not the root nor a rightmost edge,
/// must already have at least MIN_LEN elements.
pub(super) fn fix_right_border<A: Allocator + Clone>(&mut self, alloc: A) {
pub(super) fn fix_right_border<A: AllocatorClone>(&mut self, alloc: A) {
self.fix_top(alloc.clone());
if self.len() > 0 {
self.borrow_mut().last_kv().fix_right_border_of_right_edge(alloc.clone());
Expand All @@ -91,7 +88,7 @@ impl<K, V> Root<K, V> {
}

/// The symmetric clone of `fix_right_border`.
pub(super) fn fix_left_border<A: Allocator + Clone>(&mut self, alloc: A) {
pub(super) fn fix_left_border<A: AllocatorClone>(&mut self, alloc: A) {
self.fix_top(alloc.clone());
if self.len() > 0 {
self.borrow_mut().first_kv().fix_left_border_of_left_edge(alloc.clone());
Expand Down Expand Up @@ -121,14 +118,14 @@ impl<K, V> Root<K, V> {
}

impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>, marker::KV> {
fn fix_left_border_of_left_edge<A: Allocator + Clone>(mut self, alloc: A) {
fn fix_left_border_of_left_edge<A: AllocatorClone>(mut self, alloc: A) {
while let Internal(internal_kv) = self.force() {
self = internal_kv.fix_left_child(alloc.clone()).first_kv();
debug_assert!(self.reborrow().into_node().len() > MIN_LEN);
}
}

fn fix_right_border_of_right_edge<A: Allocator + Clone>(mut self, alloc: A) {
fn fix_right_border_of_right_edge<A: AllocatorClone>(mut self, alloc: A) {
while let Internal(internal_kv) = self.force() {
self = internal_kv.fix_right_child(alloc.clone()).last_kv();
debug_assert!(self.reborrow().into_node().len() > MIN_LEN);
Expand All @@ -141,7 +138,7 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
/// provisions an extra element to allow merging its children in turn
/// without becoming underfull.
/// Returns the left child.
fn fix_left_child<A: Allocator + Clone>(
fn fix_left_child<A: AllocatorClone>(
self,
alloc: A,
) -> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
Expand All @@ -164,7 +161,7 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
/// provisions an extra element to allow merging its children in turn
/// without becoming underfull.
/// Returns wherever the right child ended up.
fn fix_right_child<A: Allocator + Clone>(
fn fix_right_child<A: AllocatorClone>(
self,
alloc: A,
) -> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
Expand Down
Loading
Loading