From bd72f7ac4c2b194c104b7d3ed242fb03d8bd7076 Mon Sep 17 00:00:00 2001 From: Max Dexheimer Date: Mon, 24 Aug 2026 19:19:30 +0200 Subject: [PATCH] Replace `Allocator + Clone` with `AllocatorClone` in btree --- compiler/rustc_data_structures/src/marker.rs | 4 +- library/alloc/src/collections/btree/append.rs | 10 +- library/alloc/src/collections/btree/fix.rs | 23 ++-- library/alloc/src/collections/btree/map.rs | 116 +++++++++--------- .../alloc/src/collections/btree/map/entry.rs | 26 ++-- .../alloc/src/collections/btree/navigate.rs | 18 +-- library/alloc/src/collections/btree/node.rs | 38 +++--- library/alloc/src/collections/btree/remove.rs | 8 +- library/alloc/src/collections/btree/set.rs | 92 +++++++------- .../alloc/src/collections/btree/set/entry.rs | 20 +-- library/alloc/src/collections/btree/split.rs | 6 +- 11 files changed, 176 insertions(+), 185 deletions(-) diff --git a/compiler/rustc_data_structures/src/marker.rs b/compiler/rustc_data_structures/src/marker.rs index 2fe2a30c36751..505a7a4c9d465 100644 --- a/compiler/rustc_data_structures/src/marker.rs +++ b/compiler/rustc_data_structures/src/marker.rs @@ -85,7 +85,7 @@ impl_dyn_send!( [std::sync::LazyLock where T: DynSend, F: DynSend] [std::collections::HashSet where K: DynSend, S: DynSend] [std::collections::HashMap where K: DynSend, V: DynSend, S: DynSend] - [std::collections::BTreeMap where K: DynSend, V: DynSend, A: std::alloc::Allocator + Clone + DynSend] + [std::collections::BTreeMap where K: DynSend, V: DynSend, A: std::alloc::AllocatorClone + DynSend] [Vec where T: DynSend, A: std::alloc::Allocator + DynSend] [Box where T: ?Sized + DynSend, A: std::alloc::Allocator + DynSend] [crate::sync::RwLock where T: DynSend] @@ -168,7 +168,7 @@ impl_dyn_sync!( [std::sync::LazyLock where T: DynSend + DynSync, F: DynSend] [std::collections::HashSet where K: DynSync, S: DynSync] [std::collections::HashMap where K: DynSync, V: DynSync, S: DynSync] - [std::collections::BTreeMap where K: DynSync, V: DynSync, A: std::alloc::Allocator + Clone + DynSync] + [std::collections::BTreeMap where K: DynSync, V: DynSync, A: std::alloc::AllocatorClone + DynSync] [Vec where T: DynSync, A: std::alloc::Allocator + DynSync] [Box where T: ?Sized + DynSync, A: std::alloc::Allocator + DynSync] [crate::sync::RwLock where T: DynSend + DynSync] diff --git a/library/alloc/src/collections/btree/append.rs b/library/alloc/src/collections/btree/append.rs index cc8d793e98e4d..4f11b1f6ea432 100644 --- a/library/alloc/src/collections/btree/append.rs +++ b/library/alloc/src/collections/btree/append.rs @@ -1,4 +1,4 @@ -use core::alloc::Allocator; +use core::alloc::AllocatorClone; use super::node::{self, Root}; @@ -6,12 +6,8 @@ impl Root { /// 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( - &mut self, - iter: I, - length: &mut usize, - alloc: A, - ) where + pub(super) fn bulk_push(&mut self, iter: I, length: &mut usize, alloc: A) + where I: Iterator, { let mut cur_node = self.borrow_mut().last_leaf_edge().into_node(); diff --git a/library/alloc/src/collections/btree/fix.rs b/library/alloc/src/collections/btree/fix.rs index b0c6759794691..0b36c203c1170 100644 --- a/library/alloc/src/collections/btree/fix.rs +++ b/library/alloc/src/collections/btree/fix.rs @@ -1,4 +1,4 @@ -use core::alloc::Allocator; +use core::alloc::AllocatorClone; use super::map::MIN_LEN; use super::node::ForceResult::*; @@ -10,7 +10,7 @@ impl<'a, K: 'a, V: 'a> NodeRef, 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( + fn fix_node_through_parent( self, alloc: A, ) -> Result, K, V, marker::Internal>>, Self> { @@ -57,10 +57,7 @@ impl<'a, K: 'a, V: 'a> NodeRef, 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( - mut self, - alloc: A, - ) -> bool { + pub(super) fn fix_node_and_affected_ancestors(mut self, alloc: A) -> bool { loop { match self.fix_node_through_parent(alloc.clone()) { Ok(Some(parent)) => self = parent.forget_type(), @@ -73,7 +70,7 @@ impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::LeafOrInternal> { impl Root { /// Removes empty levels on the top, but keeps an empty leaf if the entire tree is empty. - pub(super) fn fix_top(&mut self, alloc: A) { + pub(super) fn fix_top(&mut self, alloc: A) { while self.height() > 0 && self.len() == 0 { self.pop_internal_level(alloc.clone()); } @@ -82,7 +79,7 @@ impl Root { /// 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(&mut self, alloc: A) { + pub(super) fn fix_right_border(&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()); @@ -91,7 +88,7 @@ impl Root { } /// The symmetric clone of `fix_right_border`. - pub(super) fn fix_left_border(&mut self, alloc: A) { + pub(super) fn fix_left_border(&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()); @@ -121,14 +118,14 @@ impl Root { } impl<'a, K: 'a, V: 'a> Handle, K, V, marker::LeafOrInternal>, marker::KV> { - fn fix_left_border_of_left_edge(mut self, alloc: A) { + fn fix_left_border_of_left_edge(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(mut self, alloc: A) { + fn fix_right_border_of_right_edge(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); @@ -141,7 +138,7 @@ impl<'a, K: 'a, V: 'a> Handle, 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( + fn fix_left_child( self, alloc: A, ) -> NodeRef, K, V, marker::LeafOrInternal> { @@ -164,7 +161,7 @@ impl<'a, K: 'a, V: 'a> Handle, 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( + fn fix_right_child( self, alloc: A, ) -> NodeRef, K, V, marker::LeafOrInternal> { diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index d8421d3c3f70a..aed07b3a5e901 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -17,7 +17,7 @@ use super::node::{self, Handle, NodeRef, Root, marker}; use super::search::SearchBound; use super::search::SearchResult::*; use super::set_val::SetValZST; -use crate::alloc::{Allocator, Global}; +use crate::alloc::{AllocatorClone, Global}; use crate::vec::Vec; mod entry; @@ -189,7 +189,7 @@ pub(super) const MIN_LEN: usize = node::MIN_LEN_AFTER_SPLIT; pub struct BTreeMap< K, V, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { root: Option>, length: usize, @@ -203,7 +203,7 @@ pub struct BTreeMap< } #[stable(feature = "btree_drop", since = "1.7.0")] -unsafe impl<#[may_dangle] K, #[may_dangle] V, A: Allocator + Clone> Drop for BTreeMap { +unsafe impl<#[may_dangle] K, #[may_dangle] V, A: AllocatorClone> Drop for BTreeMap { fn drop(&mut self) { drop(unsafe { ptr::read(self) }.into_iter()) } @@ -214,7 +214,7 @@ unsafe impl<#[may_dangle] K, #[may_dangle] V, A: Allocator + Clone> Drop for BTr // Maybe we can fix it nonetheless with a crater run, or if the `UnwindSafe` // traits are deprecated, or disarmed (no longer causing hard errors) in the future. #[stable(feature = "btree_unwindsafe", since = "1.64.0")] -impl core::panic::UnwindSafe for BTreeMap +impl core::panic::UnwindSafe for BTreeMap where A: core::panic::UnwindSafe, K: core::panic::RefUnwindSafe, @@ -223,9 +223,9 @@ where } #[stable(feature = "rust1", since = "1.0.0")] -impl Clone for BTreeMap { +impl Clone for BTreeMap { fn clone(&self) -> BTreeMap { - fn clone_subtree<'a, K: Clone, V: Clone, A: Allocator + Clone>( + fn clone_subtree<'a, K: Clone, V: Clone, A: AllocatorClone>( node: NodeRef, K, V, marker::LeafOrInternal>, alloc: A, ) -> BTreeMap @@ -309,7 +309,7 @@ impl Clone for BTreeMap { } // Internal functionality for `BTreeSet`. -impl BTreeMap { +impl BTreeMap { pub(super) fn replace(&mut self, key: K) -> Option where K: Ord, @@ -444,7 +444,7 @@ impl<'a, K: 'a, V: 'a> Default for IterMut<'a, K, V> { pub struct IntoIter< K, V, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { range: LazyLeafRange, length: usize, @@ -452,7 +452,7 @@ pub struct IntoIter< alloc: A, } -impl IntoIter { +impl IntoIter { /// Returns an iterator of references over the remaining items. #[inline] pub(super) fn iter(&self) -> Iter<'_, K, V> { @@ -461,7 +461,7 @@ impl IntoIter { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl Debug for IntoIter { +impl Debug for IntoIter { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.iter()).finish() } @@ -470,7 +470,7 @@ impl Debug for IntoIter { #[stable(feature = "default_iters", since = "1.70.0")] impl Default for IntoIter where - A: Allocator + Default + Clone, + A: AllocatorClone + Default, { /// Creates an empty `btree_map::IntoIter`. /// @@ -552,13 +552,13 @@ impl fmt::Debug for ValuesMut<'_, K, V> { pub struct IntoKeys< K, V, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { inner: IntoIter, } #[stable(feature = "map_into_keys_values", since = "1.54.0")] -impl fmt::Debug for IntoKeys { +impl fmt::Debug for IntoKeys { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.inner.iter().map(|(key, _)| key)).finish() } @@ -575,13 +575,13 @@ impl fmt::Debug for IntoKeys { pub struct IntoValues< K, V, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { inner: IntoIter, } #[stable(feature = "map_into_keys_values", since = "1.54.0")] -impl fmt::Debug for IntoValues { +impl fmt::Debug for IntoValues { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.inner.iter().map(|(_, val)| val)).finish() } @@ -653,7 +653,7 @@ impl BTreeMap { } } -impl BTreeMap { +impl BTreeMap { /// Clears the map, removing all elements. /// /// # Examples @@ -697,7 +697,7 @@ impl BTreeMap { } } -impl BTreeMap { +impl BTreeMap { /// Returns a reference to the value corresponding to the key. /// /// The key may be any borrowed form of the map's key type, but the ordering @@ -1719,7 +1719,7 @@ impl BTreeMap { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K, V, A: Allocator + Clone> IntoIterator for &'a BTreeMap { +impl<'a, K, V, A: AllocatorClone> IntoIterator for &'a BTreeMap { type Item = (&'a K, &'a V); type IntoIter = Iter<'a, K, V>; @@ -1797,7 +1797,7 @@ impl Clone for Iter<'_, K, V> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K, V, A: Allocator + Clone> IntoIterator for &'a mut BTreeMap { +impl<'a, K, V, A: AllocatorClone> IntoIterator for &'a mut BTreeMap { type Item = (&'a K, &'a mut V); type IntoIter = IterMut<'a, K, V>; @@ -1876,7 +1876,7 @@ impl<'a, K, V> IterMut<'a, K, V> { } #[stable(feature = "rust1", since = "1.0.0")] -impl IntoIterator for BTreeMap { +impl IntoIterator for BTreeMap { type Item = (K, V); type IntoIter = IntoIter; @@ -1902,11 +1902,11 @@ impl IntoIterator for BTreeMap { } #[stable(feature = "btree_drop", since = "1.7.0")] -impl Drop for IntoIter { +impl Drop for IntoIter { fn drop(&mut self) { - struct DropGuard<'a, K, V, A: Allocator + Clone>(&'a mut IntoIter); + struct DropGuard<'a, K, V, A: AllocatorClone>(&'a mut IntoIter); - impl<'a, K, V, A: Allocator + Clone> Drop for DropGuard<'a, K, V, A> { + impl<'a, K, V, A: AllocatorClone> Drop for DropGuard<'a, K, V, A> { fn drop(&mut self) { // Continue the same loop we perform below. This only runs when unwinding, so we // don't have to care about panics this time (they'll abort). @@ -1926,7 +1926,7 @@ impl Drop for IntoIter { } } -impl IntoIter { +impl IntoIter { /// Core of a `next` method returning a dying KV handle, /// invalidated by further calls to this function and some others. fn dying_next( @@ -1957,7 +1957,7 @@ impl IntoIter { } #[stable(feature = "rust1", since = "1.0.0")] -impl Iterator for IntoIter { +impl Iterator for IntoIter { type Item = (K, V); fn next(&mut self) -> Option<(K, V)> { @@ -1971,7 +1971,7 @@ impl Iterator for IntoIter { } #[stable(feature = "rust1", since = "1.0.0")] -impl DoubleEndedIterator for IntoIter { +impl DoubleEndedIterator for IntoIter { fn next_back(&mut self) -> Option<(K, V)> { // SAFETY: we consume the dying handle immediately. self.dying_next_back().map(unsafe { |kv| kv.into_key_val() }) @@ -1979,17 +1979,17 @@ impl DoubleEndedIterator for IntoIter { } #[stable(feature = "rust1", since = "1.0.0")] -impl ExactSizeIterator for IntoIter { +impl ExactSizeIterator for IntoIter { fn len(&self) -> usize { self.length } } #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl TrustedLen for IntoIter {} +unsafe impl TrustedLen for IntoIter {} #[stable(feature = "fused", since = "1.26.0")] -impl FusedIterator for IntoIter {} +impl FusedIterator for IntoIter {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, K, V> Iterator for Keys<'a, K, V> { @@ -2133,7 +2133,7 @@ pub struct ExtractIf< V, R, F, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { pred: F, inner: ExtractIfInner<'a, K, V, R>, @@ -2163,7 +2163,7 @@ impl fmt::Debug for ExtractIf<'_, K, V, R, F, A> where K: fmt::Debug, V: fmt::Debug, - A: Allocator + Clone, + A: AllocatorClone, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("ExtractIf").field("peek", &self.inner.peek()).finish_non_exhaustive() @@ -2171,7 +2171,7 @@ where } #[stable(feature = "btree_extract_if", since = "1.91.0")] -impl Iterator for ExtractIf<'_, K, V, R, F, A> +impl Iterator for ExtractIf<'_, K, V, R, F, A> where K: PartialOrd, R: RangeBounds, @@ -2196,7 +2196,7 @@ impl<'a, K, V, R> ExtractIfInner<'a, K, V, R> { } /// Implementation of a typical `ExtractIf::next` method, given the predicate. - pub(super) fn next(&mut self, pred: &mut F, alloc: A) -> Option<(K, V)> + pub(super) fn next(&mut self, pred: &mut F, alloc: A) -> Option<(K, V)> where K: PartialOrd, R: RangeBounds, @@ -2360,7 +2360,7 @@ impl Default for ValuesMut<'_, K, V> { } #[stable(feature = "map_into_keys_values", since = "1.54.0")] -impl Iterator for IntoKeys { +impl Iterator for IntoKeys { type Item = K; fn next(&mut self) -> Option { @@ -2391,29 +2391,29 @@ impl Iterator for IntoKeys { } #[stable(feature = "map_into_keys_values", since = "1.54.0")] -impl DoubleEndedIterator for IntoKeys { +impl DoubleEndedIterator for IntoKeys { fn next_back(&mut self) -> Option { self.inner.next_back().map(|(k, _)| k) } } #[stable(feature = "map_into_keys_values", since = "1.54.0")] -impl ExactSizeIterator for IntoKeys { +impl ExactSizeIterator for IntoKeys { fn len(&self) -> usize { self.inner.len() } } #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl TrustedLen for IntoKeys {} +unsafe impl TrustedLen for IntoKeys {} #[stable(feature = "map_into_keys_values", since = "1.54.0")] -impl FusedIterator for IntoKeys {} +impl FusedIterator for IntoKeys {} #[stable(feature = "default_iters", since = "1.70.0")] impl Default for IntoKeys where - A: Allocator + Default + Clone, + A: AllocatorClone + Default, { /// Creates an empty `btree_map::IntoKeys`. /// @@ -2428,7 +2428,7 @@ where } #[stable(feature = "map_into_keys_values", since = "1.54.0")] -impl Iterator for IntoValues { +impl Iterator for IntoValues { type Item = V; fn next(&mut self) -> Option { @@ -2445,29 +2445,29 @@ impl Iterator for IntoValues { } #[stable(feature = "map_into_keys_values", since = "1.54.0")] -impl DoubleEndedIterator for IntoValues { +impl DoubleEndedIterator for IntoValues { fn next_back(&mut self) -> Option { self.inner.next_back().map(|(_, v)| v) } } #[stable(feature = "map_into_keys_values", since = "1.54.0")] -impl ExactSizeIterator for IntoValues { +impl ExactSizeIterator for IntoValues { fn len(&self) -> usize { self.inner.len() } } #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl TrustedLen for IntoValues {} +unsafe impl TrustedLen for IntoValues {} #[stable(feature = "map_into_keys_values", since = "1.54.0")] -impl FusedIterator for IntoValues {} +impl FusedIterator for IntoValues {} #[stable(feature = "default_iters", since = "1.70.0")] impl Default for IntoValues where - A: Allocator + Default + Clone, + A: AllocatorClone + Default, { /// Creates an empty `btree_map::IntoValues`. /// @@ -2555,7 +2555,7 @@ impl FromIterator<(K, V)> for BTreeMap { } #[stable(feature = "rust1", since = "1.0.0")] -impl Extend<(K, V)> for BTreeMap { +impl Extend<(K, V)> for BTreeMap { #[inline] fn extend>(&mut self, iter: T) { iter.into_iter().for_each(move |(k, v)| { @@ -2570,9 +2570,7 @@ impl Extend<(K, V)> for BTreeMap { } #[stable(feature = "extend_ref", since = "1.2.0")] -impl<'a, K: Ord + Copy, V: Copy, A: Allocator + Clone> Extend<(&'a K, &'a V)> - for BTreeMap -{ +impl<'a, K: Ord + Copy, V: Copy, A: AllocatorClone> Extend<(&'a K, &'a V)> for BTreeMap { fn extend>(&mut self, iter: I) { self.extend(iter.into_iter().map(|(&key, &value)| (key, value))); } @@ -2584,7 +2582,7 @@ impl<'a, K: Ord + Copy, V: Copy, A: Allocator + Clone> Extend<(&'a K, &'a V)> } #[stable(feature = "rust1", since = "1.0.0")] -impl Hash for BTreeMap { +impl Hash for BTreeMap { fn hash(&self, state: &mut H) { state.write_length_prefix(self.len()); for elt in self { @@ -2603,17 +2601,17 @@ const impl Default for BTreeMap { } #[stable(feature = "rust1", since = "1.0.0")] -impl PartialEq for BTreeMap { +impl PartialEq for BTreeMap { fn eq(&self, other: &BTreeMap) -> bool { self.len() == other.len() && self.iter().zip(other).all(|(a, b)| a == b) } } #[stable(feature = "rust1", since = "1.0.0")] -impl Eq for BTreeMap {} +impl Eq for BTreeMap {} #[stable(feature = "rust1", since = "1.0.0")] -impl PartialOrd for BTreeMap { +impl PartialOrd for BTreeMap { #[inline] fn partial_cmp(&self, other: &BTreeMap) -> Option { self.iter().partial_cmp(other.iter()) @@ -2621,7 +2619,7 @@ impl PartialOrd for BTreeMap } #[stable(feature = "rust1", since = "1.0.0")] -impl Ord for BTreeMap { +impl Ord for BTreeMap { #[inline] fn cmp(&self, other: &BTreeMap) -> Ordering { self.iter().cmp(other.iter()) @@ -2629,14 +2627,14 @@ impl Ord for BTreeMap { } #[stable(feature = "rust1", since = "1.0.0")] -impl Debug for BTreeMap { +impl Debug for BTreeMap { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_map().entries(self.iter()).finish() } } #[stable(feature = "rust1", since = "1.0.0")] -impl Index<&Q> for BTreeMap +impl Index<&Q> for BTreeMap where K: Borrow + Ord, Q: Ord, @@ -2679,7 +2677,7 @@ impl From<[(K, V); N]> for BTreeMap { } } -impl BTreeMap { +impl BTreeMap { /// Gets an iterator over the entries of the map, sorted by key. /// /// # Examples @@ -3422,7 +3420,7 @@ impl<'a, K, V, A> CursorMutKey<'a, K, V, A> { } // Now the tree editing operations -impl<'a, K: Ord, V, A: Allocator + Clone> CursorMutKey<'a, K, V, A> { +impl<'a, K: Ord, V, A: AllocatorClone> CursorMutKey<'a, K, V, A> { /// Inserts a new key-value pair into the map in the gap that the /// cursor is currently pointing to. /// @@ -3627,7 +3625,7 @@ impl<'a, K: Ord, V, A: Allocator + Clone> CursorMutKey<'a, K, V, A> { } } -impl<'a, K: Ord, V, A: Allocator + Clone> CursorMut<'a, K, V, A> { +impl<'a, K: Ord, V, A: AllocatorClone> CursorMut<'a, K, V, A> { /// Inserts a new key-value pair into the map in the gap that the /// cursor is currently pointing to. /// diff --git a/library/alloc/src/collections/btree/map/entry.rs b/library/alloc/src/collections/btree/map/entry.rs index 1c2ad5c568e6a..d3a9651799ab8 100644 --- a/library/alloc/src/collections/btree/map/entry.rs +++ b/library/alloc/src/collections/btree/map/entry.rs @@ -7,7 +7,7 @@ use Entry::*; use super::super::borrow::DormantMutRef; use super::super::node::{Handle, NodeRef, marker}; use super::BTreeMap; -use crate::alloc::{Allocator, Global}; +use crate::alloc::{AllocatorClone, Global}; /// A view into a single entry in a map, which may either be vacant or occupied. /// @@ -20,7 +20,7 @@ pub enum Entry< 'a, K: 'a, V: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { /// A vacant entry. #[stable(feature = "rust1", since = "1.0.0")] @@ -32,7 +32,7 @@ pub enum Entry< } #[stable(feature = "debug_btree_map", since = "1.12.0")] -impl Debug for Entry<'_, K, V, A> { +impl Debug for Entry<'_, K, V, A> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Vacant(ref v) => f.debug_tuple("Entry").field(v).finish(), @@ -48,7 +48,7 @@ pub struct VacantEntry< 'a, K, V, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { pub(super) key: K, /// `None` for a (empty) map without root @@ -63,7 +63,7 @@ pub struct VacantEntry< } #[stable(feature = "debug_btree_map", since = "1.12.0")] -impl Debug for VacantEntry<'_, K, V, A> { +impl Debug for VacantEntry<'_, K, V, A> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("VacantEntry").field(self.key()).finish() } @@ -76,7 +76,7 @@ pub struct OccupiedEntry< 'a, K, V, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { pub(super) handle: Handle, K, V, marker::LeafOrInternal>, marker::KV>, pub(super) dormant_map: DormantMutRef<'a, BTreeMap>, @@ -89,7 +89,7 @@ pub struct OccupiedEntry< } #[stable(feature = "debug_btree_map", since = "1.12.0")] -impl Debug for OccupiedEntry<'_, K, V, A> { +impl Debug for OccupiedEntry<'_, K, V, A> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("OccupiedEntry").field("key", self.key()).field("value", self.get()).finish() } @@ -104,7 +104,7 @@ pub struct OccupiedError< 'a, K: 'a, V: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { /// The entry in the map that was already occupied. pub entry: OccupiedEntry<'a, K, V, A>, @@ -115,7 +115,7 @@ pub struct OccupiedError< } #[unstable(feature = "map_try_insert", issue = "82766")] -impl Debug for OccupiedError<'_, K, V, A> { +impl Debug for OccupiedError<'_, K, V, A> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("OccupiedError") .field("key", self.entry.key()) @@ -126,7 +126,7 @@ impl Debug for OccupiedError<'_, } } -impl<'a, K: Ord, V, A: Allocator + Clone> Entry<'a, K, V, A> { +impl<'a, K: Ord, V, A: AllocatorClone> Entry<'a, K, V, A> { /// Ensures a value is in the entry by inserting the default if empty, and returns /// a mutable reference to the value in the entry. /// @@ -345,7 +345,7 @@ impl<'a, K: Ord, V, A: Allocator + Clone> Entry<'a, K, V, A> { } } -impl<'a, K: Ord, V: Default, A: Allocator + Clone> Entry<'a, K, V, A> { +impl<'a, K: Ord, V: Default, A: AllocatorClone> Entry<'a, K, V, A> { #[stable(feature = "entry_or_default", since = "1.28.0")] /// Ensures a value is in the entry by inserting the default value if empty, /// and returns a mutable reference to the value in the entry. @@ -368,7 +368,7 @@ impl<'a, K: Ord, V: Default, A: Allocator + Clone> Entry<'a, K, V, A> { } } -impl<'a, K: Ord, V, A: Allocator + Clone> VacantEntry<'a, K, V, A> { +impl<'a, K: Ord, V, A: AllocatorClone> VacantEntry<'a, K, V, A> { /// Gets a reference to the key that would be used when inserting a value /// through the VacantEntry. /// @@ -479,7 +479,7 @@ impl<'a, K: Ord, V, A: Allocator + Clone> VacantEntry<'a, K, V, A> { } } -impl<'a, K: Ord, V, A: Allocator + Clone> OccupiedEntry<'a, K, V, A> { +impl<'a, K: Ord, V, A: AllocatorClone> OccupiedEntry<'a, K, V, A> { /// Gets a reference to the key in the entry. /// /// # Examples diff --git a/library/alloc/src/collections/btree/navigate.rs b/library/alloc/src/collections/btree/navigate.rs index b2a7de74875d9..d5b514e67e82e 100644 --- a/library/alloc/src/collections/btree/navigate.rs +++ b/library/alloc/src/collections/btree/navigate.rs @@ -5,7 +5,7 @@ use core::{hint, ptr}; use super::node::ForceResult::*; use super::node::{Handle, NodeRef, marker}; use super::search::SearchBound; -use crate::alloc::Allocator; +use crate::alloc::AllocatorClone; // `front` and `back` are always both `None` or both `Some`. pub(super) struct LeafRange { front: Option, marker::Edge>>, @@ -190,7 +190,7 @@ impl LazyLeafRange { } #[inline] - pub(super) unsafe fn deallocating_next_unchecked( + pub(super) unsafe fn deallocating_next_unchecked( &mut self, alloc: A, ) -> Handle, marker::KV> { @@ -200,7 +200,7 @@ impl LazyLeafRange { } #[inline] - pub(super) unsafe fn deallocating_next_back_unchecked( + pub(super) unsafe fn deallocating_next_back_unchecked( &mut self, alloc: A, ) -> Handle, marker::KV> { @@ -210,7 +210,7 @@ impl LazyLeafRange { } #[inline] - pub(super) fn deallocating_end(&mut self, alloc: A) { + pub(super) fn deallocating_end(&mut self, alloc: A) { if let Some(front) = self.take_front() { front.deallocating_end(alloc) } @@ -456,7 +456,7 @@ impl Handle, marker::Edge> { /// `deallocating_next_back`. /// - The returned KV handle is only valid to access the key and value, /// and only valid until the next call to a `deallocating_` method. - unsafe fn deallocating_next( + unsafe fn deallocating_next( self, alloc: A, ) -> Option<(Self, Handle, marker::KV>)> @@ -488,7 +488,7 @@ impl Handle, marker::Edge> { /// `deallocating_next`. /// - The returned KV handle is only valid to access the key and value, /// and only valid until the next call to a `deallocating_` method. - unsafe fn deallocating_next_back( + unsafe fn deallocating_next_back( self, alloc: A, ) -> Option<(Self, Handle, marker::KV>)> @@ -513,7 +513,7 @@ impl Handle, marker::Edge> { /// both sides of the tree, and have hit the same edge. As it is intended /// only to be called when all keys and values have been returned, /// no cleanup is done on any of the keys or values. - fn deallocating_end(self, alloc: A) { + fn deallocating_end(self, alloc: A) { let mut edge = self.forget_node_type(); while let Some(parent_edge) = unsafe { edge.into_node().deallocate_and_ascend(alloc.clone()) } @@ -592,7 +592,7 @@ impl Handle, marker::Edge> { /// /// The only safe way to proceed with the updated handle is to compare it, drop it, /// or call this method or counterpart `deallocating_next_back_unchecked` again. - unsafe fn deallocating_next_unchecked( + unsafe fn deallocating_next_unchecked( &mut self, alloc: A, ) -> Handle, marker::KV> { @@ -613,7 +613,7 @@ impl Handle, marker::Edge> { /// /// The only safe way to proceed with the updated handle is to compare it, drop it, /// or call this method or counterpart `deallocating_next_unchecked` again. - unsafe fn deallocating_next_back_unchecked( + unsafe fn deallocating_next_back_unchecked( &mut self, alloc: A, ) -> Handle, marker::KV> { diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index 0c7afcc63b9b7..8088fec38ed6a 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -37,7 +37,7 @@ use core::num::NonZero; use core::ptr::{self, NonNull}; use core::slice::SliceIndex; -use crate::alloc::{Allocator, Layout}; +use crate::alloc::{Allocator, AllocatorClone, Layout}; use crate::boxed::Box; const B: usize = 6; @@ -83,7 +83,7 @@ impl LeafNode { } /// Creates a new boxed `LeafNode`. - fn new(alloc: A) -> Box { + fn new(alloc: A) -> Box { let mut leaf = Box::new_uninit_in(alloc); unsafe { // SAFETY: `leaf` points to a `LeafNode` @@ -117,7 +117,7 @@ impl InternalNode { /// An invariant of internal nodes is that they have at least one /// initialized and valid edge. This function does not set up /// such an edge. - unsafe fn new(alloc: A) -> Box { + unsafe fn new(alloc: A) -> Box { let mut node = Box::::new_uninit_in(alloc); unsafe { // SAFETY: argument points to the `node.data` `LeafNode` @@ -221,11 +221,11 @@ unsafe impl Send for NodeRef unsafe impl Send for NodeRef {} impl NodeRef { - pub(super) fn new_leaf(alloc: A) -> Self { + pub(super) fn new_leaf(alloc: A) -> Self { Self::from_new_leaf(LeafNode::new(alloc)) } - fn from_new_leaf(leaf: Box, A>) -> Self { + fn from_new_leaf(leaf: Box, A>) -> Self { // The allocator must be dropped, not leaked. See also `BTreeMap::alloc`. let (node, _alloc) = Box::into_non_null_with_allocator(leaf); NodeRef { height: 0, node, _marker: PhantomData } @@ -234,14 +234,14 @@ impl NodeRef { impl NodeRef { /// Creates a new internal (height > 0) `NodeRef` - fn new_internal(child: Root, alloc: A) -> Self { + fn new_internal(child: Root, alloc: A) -> Self { let mut new_node = unsafe { InternalNode::new(alloc) }; new_node.edges[0].write(child.node); NodeRef::from_new_internal(new_node, NonZero::new(child.height + 1).unwrap()) } /// Creates a new internal (height > 0) `NodeRef` from an existing internal node - fn from_new_internal( + fn from_new_internal( internal: Box, A>, height: NonZero, ) -> Self { @@ -401,7 +401,7 @@ impl NodeRef { /// Similar to `ascend`, gets a reference to a node's parent node, but also /// deallocates the current node in the process. This is unsafe because the /// current node will still be accessible despite being deallocated. - pub(super) unsafe fn deallocate_and_ascend( + pub(super) unsafe fn deallocate_and_ascend( self, alloc: A, ) -> Option, marker::Edge>> { @@ -588,14 +588,14 @@ impl NodeRef { impl NodeRef { /// Returns a new owned tree, with its own root node that is initially empty. - pub(super) fn new(alloc: A) -> Self { + pub(super) fn new(alloc: A) -> Self { NodeRef::new_leaf(alloc).forget_type() } /// Adds a new internal node with a single edge pointing to the previous root node, /// make that new node the root node, and return it. This increases the height by 1 /// and is the opposite of `pop_internal_level`. - pub(super) fn push_internal_level( + pub(super) fn push_internal_level( &mut self, alloc: A, ) -> NodeRef, K, V, marker::Internal> { @@ -614,7 +614,7 @@ impl NodeRef { /// rooted at the first child of `self`. /// /// Panics if there is no internal level, i.e., if the root node is a leaf. - pub(super) fn pop_internal_level(&mut self, alloc: A) { + pub(super) fn pop_internal_level(&mut self, alloc: A) { assert!(self.height > 0); let top = self.node; @@ -950,7 +950,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Leaf>, mark /// /// Returns a dormant handle to the inserted node which can be reawakened /// once splitting is complete. - fn insert( + fn insert( self, key: K, val: V, @@ -1017,7 +1017,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Internal>, /// Inserts a new key-value pair and an edge that will go to the right of that new pair /// between this edge and the key-value pair to the right of this edge. This method splits /// the node if there isn't enough room. - fn insert( + fn insert( mut self, key: K, val: V, @@ -1055,7 +1055,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Leaf>, mark /// If the returned result is some `SplitResult`, the `left` field will be the root node. /// The returned pointer points to the inserted value, which in the case of `SplitResult` /// is in the `left` or `right` tree. - pub(super) fn insert_recursing( + pub(super) fn insert_recursing( self, key: K, value: V, @@ -1250,7 +1250,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Leaf>, mark /// - 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(super) fn split( + pub(super) fn split( mut self, alloc: A, ) -> SplitResult<'a, K, V, marker::Leaf> { @@ -1285,7 +1285,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Internal>, /// - 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(super) fn split( + pub(super) fn split( mut self, alloc: A, ) -> SplitResult<'a, K, V, marker::Internal> { @@ -1458,7 +1458,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> { /// the left child node and returns the shrunk parent node. /// /// Panics unless we `.can_merge()`. - pub(super) fn merge_tracking_parent( + pub(super) fn merge_tracking_parent( self, alloc: A, ) -> NodeRef, K, V, marker::Internal> { @@ -1469,7 +1469,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> { /// the left child node and returns that child node. /// /// Panics unless we `.can_merge()`. - pub(super) fn merge_tracking_child( + pub(super) fn merge_tracking_child( self, alloc: A, ) -> NodeRef, K, V, marker::LeafOrInternal> { @@ -1481,7 +1481,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> { /// where the tracked child edge ended up, /// /// Panics unless we `.can_merge()`. - pub(super) fn merge_tracking_child_edge( + pub(super) fn merge_tracking_child_edge( self, track_edge_idx: LeftOrRight, alloc: A, diff --git a/library/alloc/src/collections/btree/remove.rs b/library/alloc/src/collections/btree/remove.rs index 9d870b86f34a0..b21c7e78b5bb3 100644 --- a/library/alloc/src/collections/btree/remove.rs +++ b/library/alloc/src/collections/btree/remove.rs @@ -1,4 +1,4 @@ -use core::alloc::Allocator; +use core::alloc::AllocatorClone; use super::map::MIN_LEN; use super::node::ForceResult::*; @@ -10,7 +10,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::LeafOrInter /// the leaf edge corresponding to that former pair. It's possible this empties /// a root node that is internal, which the caller should pop from the map /// holding the tree. The caller should also decrement the map's length. - pub(super) fn remove_kv_tracking( + pub(super) fn remove_kv_tracking( self, handle_emptied_internal_root: F, alloc: A, @@ -23,7 +23,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::LeafOrInter } impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Leaf>, marker::KV> { - fn remove_leaf_kv( + fn remove_leaf_kv( self, handle_emptied_internal_root: F, alloc: A, @@ -76,7 +76,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Leaf>, mark } impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Internal>, marker::KV> { - fn remove_internal_kv( + fn remove_internal_kv( self, handle_emptied_internal_root: F, alloc: A, diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index d06daa7c6c1b7..78b88eafea9b9 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -10,7 +10,7 @@ use core::ops::{BitAnd, BitOr, BitXor, Bound, RangeBounds, Sub}; use super::map::{self, BTreeMap, Keys}; use super::merge_iter::MergeIterInner; use super::set_val::SetValZST; -use crate::alloc::{Allocator, Global}; +use crate::alloc::{AllocatorClone, Global}; use crate::vec::Vec; mod entry; @@ -77,44 +77,44 @@ pub use self::entry::{Entry, OccupiedEntry, VacantEntry}; #[cfg_attr(not(test), rustc_diagnostic_item = "BTreeSet")] pub struct BTreeSet< T, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { map: BTreeMap, } #[stable(feature = "rust1", since = "1.0.0")] -impl Hash for BTreeSet { +impl Hash for BTreeSet { fn hash(&self, state: &mut H) { self.map.hash(state) } } #[stable(feature = "rust1", since = "1.0.0")] -impl PartialEq for BTreeSet { +impl PartialEq for BTreeSet { fn eq(&self, other: &BTreeSet) -> bool { self.map.eq(&other.map) } } #[stable(feature = "rust1", since = "1.0.0")] -impl Eq for BTreeSet {} +impl Eq for BTreeSet {} #[stable(feature = "rust1", since = "1.0.0")] -impl PartialOrd for BTreeSet { +impl PartialOrd for BTreeSet { fn partial_cmp(&self, other: &BTreeSet) -> Option { self.map.partial_cmp(&other.map) } } #[stable(feature = "rust1", since = "1.0.0")] -impl Ord for BTreeSet { +impl Ord for BTreeSet { fn cmp(&self, other: &BTreeSet) -> Ordering { self.map.cmp(&other.map) } } #[stable(feature = "rust1", since = "1.0.0")] -impl Clone for BTreeSet { +impl Clone for BTreeSet { fn clone(&self) -> Self { BTreeSet { map: self.map.clone() } } @@ -153,7 +153,7 @@ impl fmt::Debug for Iter<'_, T> { #[derive(Debug)] pub struct IntoIter< T, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { iter: super::map::IntoIter, } @@ -183,11 +183,11 @@ pub struct Range<'a, T: 'a> { pub struct Difference< 'a, T: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { inner: DifferenceInner<'a, T, A>, } -enum DifferenceInner<'a, T: 'a, A: Allocator + Clone> { +enum DifferenceInner<'a, T: 'a, A: AllocatorClone> { Stitch { // iterate all of `self` and some of `other`, spotting matches along the way self_iter: Iter<'a, T>, @@ -202,7 +202,7 @@ enum DifferenceInner<'a, T: 'a, A: Allocator + Clone> { } // Explicit Debug impl necessary because of issue #26925 -impl Debug for DifferenceInner<'_, T, A> { +impl Debug for DifferenceInner<'_, T, A> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { DifferenceInner::Stitch { self_iter, other_iter } => f @@ -221,7 +221,7 @@ impl Debug for DifferenceInner<'_, T, A> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl fmt::Debug for Difference<'_, T, A> { +impl fmt::Debug for Difference<'_, T, A> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Difference").field(&self.inner).finish() } @@ -257,11 +257,11 @@ impl fmt::Debug for SymmetricDifference<'_, T> { pub struct Intersection< 'a, T: 'a, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { inner: IntersectionInner<'a, T, A>, } -enum IntersectionInner<'a, T: 'a, A: Allocator + Clone> { +enum IntersectionInner<'a, T: 'a, A: AllocatorClone> { Stitch { // iterate similarly sized sets jointly, spotting matches along the way a: Iter<'a, T>, @@ -276,7 +276,7 @@ enum IntersectionInner<'a, T: 'a, A: Allocator + Clone> { } // Explicit Debug impl necessary because of issue #26925 -impl Debug for IntersectionInner<'_, T, A> { +impl Debug for IntersectionInner<'_, T, A> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { IntersectionInner::Stitch { a, b } => { @@ -293,7 +293,7 @@ impl Debug for IntersectionInner<'_, T, A> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl Debug for Intersection<'_, T, A> { +impl Debug for Intersection<'_, T, A> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Intersection").field(&self.inner).finish() } @@ -346,7 +346,7 @@ impl BTreeSet { } } -impl BTreeSet { +impl BTreeSet { /// Makes a new `BTreeSet` with a reasonable choice of B. /// /// # Examples @@ -1481,7 +1481,7 @@ impl FromIterator for BTreeSet { } } -impl BTreeSet { +impl BTreeSet { fn from_sorted_iter>(iter: I, alloc: A) -> BTreeSet { let iter = iter.map(|k| (k, SetValZST::default())); let map = BTreeMap::bulk_build_from_sorted_iter(iter, alloc); @@ -1517,7 +1517,7 @@ impl From<[T; N]> for BTreeSet { } #[stable(feature = "rust1", since = "1.0.0")] -impl IntoIterator for BTreeSet { +impl IntoIterator for BTreeSet { type Item = T; type IntoIter = IntoIter; @@ -1539,7 +1539,7 @@ impl IntoIterator for BTreeSet { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T, A: Allocator + Clone> IntoIterator for &'a BTreeSet { +impl<'a, T, A: AllocatorClone> IntoIterator for &'a BTreeSet { type Item = &'a T; type IntoIter = Iter<'a, T>; @@ -1559,7 +1559,7 @@ pub struct ExtractIf< T, R, F, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { pred: F, inner: super::map::ExtractIfInner<'a, T, SetValZST, R>, @@ -1571,7 +1571,7 @@ pub struct ExtractIf< impl fmt::Debug for ExtractIf<'_, T, R, F, A> where T: fmt::Debug, - A: Allocator + Clone, + A: AllocatorClone, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("ExtractIf") @@ -1581,7 +1581,7 @@ where } #[stable(feature = "btree_extract_if", since = "1.91.0")] -impl Iterator for ExtractIf<'_, T, R, F, A> +impl Iterator for ExtractIf<'_, T, R, F, A> where T: PartialOrd, R: RangeBounds, @@ -1601,7 +1601,7 @@ where } #[stable(feature = "btree_extract_if", since = "1.91.0")] -impl FusedIterator for ExtractIf<'_, T, R, F, A> +impl FusedIterator for ExtractIf<'_, T, R, F, A> where T: PartialOrd, R: RangeBounds, @@ -1610,7 +1610,7 @@ where } #[stable(feature = "rust1", since = "1.0.0")] -impl Extend for BTreeSet { +impl Extend for BTreeSet { #[inline] fn extend>(&mut self, iter: Iter) { iter.into_iter().for_each(move |elem| { @@ -1625,7 +1625,7 @@ impl Extend for BTreeSet { } #[stable(feature = "extend_ref", since = "1.2.0")] -impl<'a, T: 'a + Ord + Copy, A: Allocator + Clone> Extend<&'a T> for BTreeSet { +impl<'a, T: 'a + Ord + Copy, A: AllocatorClone> Extend<&'a T> for BTreeSet { fn extend>(&mut self, iter: I) { self.extend(iter.into_iter().cloned()); } @@ -1645,7 +1645,7 @@ impl Default for BTreeSet { } #[stable(feature = "rust1", since = "1.0.0")] -impl Sub<&BTreeSet> for &BTreeSet { +impl Sub<&BTreeSet> for &BTreeSet { type Output = BTreeSet; /// Returns the difference of `self` and `rhs` as a new `BTreeSet`. @@ -1670,7 +1670,7 @@ impl Sub<&BTreeSet> for &BTreeSet BitXor<&BTreeSet> for &BTreeSet { +impl BitXor<&BTreeSet> for &BTreeSet { type Output = BTreeSet; /// Returns the symmetric difference of `self` and `rhs` as a new `BTreeSet`. @@ -1695,7 +1695,7 @@ impl BitXor<&BTreeSet> for &BTreeSet } #[stable(feature = "rust1", since = "1.0.0")] -impl BitAnd<&BTreeSet> for &BTreeSet { +impl BitAnd<&BTreeSet> for &BTreeSet { type Output = BTreeSet; /// Returns the intersection of `self` and `rhs` as a new `BTreeSet`. @@ -1720,7 +1720,7 @@ impl BitAnd<&BTreeSet> for &BTreeSet } #[stable(feature = "rust1", since = "1.0.0")] -impl BitOr<&BTreeSet> for &BTreeSet { +impl BitOr<&BTreeSet> for &BTreeSet { type Output = BTreeSet; /// Returns the union of `self` and `rhs` as a new `BTreeSet`. @@ -1745,7 +1745,7 @@ impl BitOr<&BTreeSet> for &BTreeSet< } #[stable(feature = "rust1", since = "1.0.0")] -impl Debug for BTreeSet { +impl Debug for BTreeSet { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_set().entries(self.iter()).finish() } @@ -1810,7 +1810,7 @@ unsafe impl TrustedLen for Iter<'_, T> {} impl FusedIterator for Iter<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] -impl Iterator for IntoIter { +impl Iterator for IntoIter { type Item = T; fn next(&mut self) -> Option { @@ -1837,29 +1837,29 @@ impl Default for Iter<'_, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl DoubleEndedIterator for IntoIter { +impl DoubleEndedIterator for IntoIter { fn next_back(&mut self) -> Option { self.iter.next_back().map(|(k, _)| k) } } #[stable(feature = "rust1", since = "1.0.0")] -impl ExactSizeIterator for IntoIter { +impl ExactSizeIterator for IntoIter { fn len(&self) -> usize { self.iter.len() } } #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl TrustedLen for IntoIter {} +unsafe impl TrustedLen for IntoIter {} #[stable(feature = "fused", since = "1.26.0")] -impl FusedIterator for IntoIter {} +impl FusedIterator for IntoIter {} #[stable(feature = "default_iters", since = "1.70.0")] impl Default for IntoIter where - A: Allocator + Default + Clone, + A: AllocatorClone + Default, { /// Creates an empty `btree_set::IntoIter`. /// @@ -1932,7 +1932,7 @@ impl Default for Range<'_, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl Clone for Difference<'_, T, A> { +impl Clone for Difference<'_, T, A> { fn clone(&self) -> Self { Difference { inner: match &self.inner { @@ -1949,7 +1949,7 @@ impl Clone for Difference<'_, T, A> { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: Ord, A: Allocator + Clone> Iterator for Difference<'a, T, A> { +impl<'a, T: Ord, A: AllocatorClone> Iterator for Difference<'a, T, A> { type Item = &'a T; fn next(&mut self) -> Option<&'a T> { @@ -1996,7 +1996,7 @@ impl<'a, T: Ord, A: Allocator + Clone> Iterator for Difference<'a, T, A> { } #[stable(feature = "fused", since = "1.26.0")] -impl FusedIterator for Difference<'_, T, A> {} +impl FusedIterator for Difference<'_, T, A> {} #[stable(feature = "rust1", since = "1.0.0")] impl Clone for SymmetricDifference<'_, T> { @@ -2034,7 +2034,7 @@ impl<'a, T: Ord> Iterator for SymmetricDifference<'a, T> { impl FusedIterator for SymmetricDifference<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] -impl Clone for Intersection<'_, T, A> { +impl Clone for Intersection<'_, T, A> { fn clone(&self) -> Self { Intersection { inner: match &self.inner { @@ -2050,7 +2050,7 @@ impl Clone for Intersection<'_, T, A> { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: Ord, A: Allocator + Clone> Iterator for Intersection<'a, T, A> { +impl<'a, T: Ord, A: AllocatorClone> Iterator for Intersection<'a, T, A> { type Item = &'a T; fn next(&mut self) -> Option<&'a T> { @@ -2091,7 +2091,7 @@ impl<'a, T: Ord, A: Allocator + Clone> Iterator for Intersection<'a, T, A> { } #[stable(feature = "fused", since = "1.26.0")] -impl FusedIterator for Intersection<'_, T, A> {} +impl FusedIterator for Intersection<'_, T, A> {} #[stable(feature = "rust1", since = "1.0.0")] impl Clone for Union<'_, T> { @@ -2356,7 +2356,7 @@ impl<'a, T, A> CursorMutKey<'a, T, A> { } } -impl<'a, T: Ord, A: Allocator + Clone> CursorMut<'a, T, A> { +impl<'a, T: Ord, A: AllocatorClone> CursorMut<'a, T, A> { /// Inserts a new element into the set in the gap that the /// cursor is currently pointing to. /// @@ -2442,7 +2442,7 @@ impl<'a, T: Ord, A: Allocator + Clone> CursorMut<'a, T, A> { } } -impl<'a, T: Ord, A: Allocator + Clone> CursorMutKey<'a, T, A> { +impl<'a, T: Ord, A: AllocatorClone> CursorMutKey<'a, T, A> { /// Inserts a new element into the set in the gap that the /// cursor is currently pointing to. /// diff --git a/library/alloc/src/collections/btree/set/entry.rs b/library/alloc/src/collections/btree/set/entry.rs index a60d22f9ece71..89bc09bca2f5c 100644 --- a/library/alloc/src/collections/btree/set/entry.rs +++ b/library/alloc/src/collections/btree/set/entry.rs @@ -3,7 +3,7 @@ use core::fmt::{self, Debug}; use Entry::*; use super::{SetValZST, map}; -use crate::alloc::{Allocator, Global}; +use crate::alloc::{AllocatorClone, Global}; /// A view into a single entry in a set, which may either be vacant or occupied. /// @@ -42,7 +42,7 @@ use crate::alloc::{Allocator, Global}; pub enum Entry< 'a, T, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { /// An occupied entry. /// @@ -84,7 +84,7 @@ pub enum Entry< } #[unstable(feature = "btree_set_entry", issue = "133549")] -impl Debug for Entry<'_, T, A> { +impl Debug for Entry<'_, T, A> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Vacant(ref v) => f.debug_tuple("Entry").field(v).finish(), @@ -133,13 +133,13 @@ impl Debug for Entry<'_, T, A> { pub struct OccupiedEntry< 'a, T, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { pub(super) inner: map::OccupiedEntry<'a, T, SetValZST, A>, } #[unstable(feature = "btree_set_entry", issue = "133549")] -impl Debug for OccupiedEntry<'_, T, A> { +impl Debug for OccupiedEntry<'_, T, A> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("OccupiedEntry").field("value", self.get()).finish() } @@ -175,19 +175,19 @@ impl Debug for OccupiedEntry<'_, T, A> { pub struct VacantEntry< 'a, T, - #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, + #[unstable(feature = "allocator_api", issue = "32838")] A: AllocatorClone = Global, > { pub(super) inner: map::VacantEntry<'a, T, SetValZST, A>, } #[unstable(feature = "btree_set_entry", issue = "133549")] -impl Debug for VacantEntry<'_, T, A> { +impl Debug for VacantEntry<'_, T, A> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("VacantEntry").field(self.get()).finish() } } -impl<'a, T: Ord, A: Allocator + Clone> Entry<'a, T, A> { +impl<'a, T: Ord, A: AllocatorClone> Entry<'a, T, A> { /// Sets the value of the entry, and returns an `OccupiedEntry`. /// /// # Examples @@ -266,7 +266,7 @@ impl<'a, T: Ord, A: Allocator + Clone> Entry<'a, T, A> { } } -impl<'a, T: Ord, A: Allocator + Clone> OccupiedEntry<'a, T, A> { +impl<'a, T: Ord, A: AllocatorClone> OccupiedEntry<'a, T, A> { /// Gets a reference to the value in the entry. /// /// # Examples @@ -316,7 +316,7 @@ impl<'a, T: Ord, A: Allocator + Clone> OccupiedEntry<'a, T, A> { } } -impl<'a, T: Ord, A: Allocator + Clone> VacantEntry<'a, T, A> { +impl<'a, T: Ord, A: AllocatorClone> VacantEntry<'a, T, A> { /// Gets a reference to the value that would be used when inserting /// through the `VacantEntry`. /// diff --git a/library/alloc/src/collections/btree/split.rs b/library/alloc/src/collections/btree/split.rs index 87a79e6cf3f93..5d5f379c2da44 100644 --- a/library/alloc/src/collections/btree/split.rs +++ b/library/alloc/src/collections/btree/split.rs @@ -1,4 +1,4 @@ -use core::alloc::Allocator; +use core::alloc::AllocatorClone; use core::borrow::Borrow; use super::node::ForceResult::*; @@ -31,7 +31,7 @@ impl Root { /// and if the ordering of `Q` corresponds to that of `K`. /// If `self` respects all `BTreeMap` tree invariants, then both /// `self` and the returned tree will respect those invariants. - pub(super) fn split_off( + pub(super) fn split_off( &mut self, key: &Q, alloc: A, @@ -69,7 +69,7 @@ impl Root { } /// Creates a tree consisting of empty nodes. - fn new_pillar(height: usize, alloc: A) -> Self { + fn new_pillar(height: usize, alloc: A) -> Self { let mut root = Root::new(alloc.clone()); for _ in 0..height { root.push_internal_level(alloc.clone());