Skip to content

Commit

Permalink
Auto merge of #215 - caelunshun:rename-allocator, r=Amanieu
Browse files Browse the repository at this point in the history
Account for renaming AllocRef to Allocator on nightly

`AllocRef` was renamed to `Allocator` in rust-lang/rust#79286.
  • Loading branch information
bors committed Dec 8, 2020
2 parents b226638 + b6daaf0 commit acbedaa
Show file tree
Hide file tree
Showing 8 changed files with 246 additions and 244 deletions.
68 changes: 34 additions & 34 deletions src/external_trait_impls/rayon/map.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Rayon extensions for `HashMap`.

use crate::hash_map::HashMap;
use crate::raw::{AllocRef, Global};
use crate::raw::{Allocator, Global};
use core::fmt;
use core::hash::{BuildHasher, Hash};
use rayon::iter::plumbing::UnindexedConsumer;
Expand All @@ -16,11 +16,11 @@ use rayon::iter::{FromParallelIterator, IntoParallelIterator, ParallelExtend, Pa
/// [`par_iter`]: /hashbrown/struct.HashMap.html#method.par_iter
/// [`HashMap`]: /hashbrown/struct.HashMap.html
/// [`IntoParallelRefIterator`]: https://docs.rs/rayon/1.0/rayon/iter/trait.IntoParallelRefIterator.html
pub struct ParIter<'a, K, V, S, A: AllocRef + Clone = Global> {
pub struct ParIter<'a, K, V, S, A: Allocator + Clone = Global> {
map: &'a HashMap<K, V, S, A>,
}

impl<'a, K: Sync, V: Sync, S: Sync, A: AllocRef + Clone + Sync> ParallelIterator
impl<'a, K: Sync, V: Sync, S: Sync, A: Allocator + Clone + Sync> ParallelIterator
for ParIter<'a, K, V, S, A>
{
type Item = (&'a K, &'a V);
Expand All @@ -39,14 +39,14 @@ impl<'a, K: Sync, V: Sync, S: Sync, A: AllocRef + Clone + Sync> ParallelIterator
}
}

impl<K, V, S, A: AllocRef + Clone> Clone for ParIter<'_, K, V, S, A> {
impl<K, V, S, A: Allocator + Clone> Clone for ParIter<'_, K, V, S, A> {
#[cfg_attr(feature = "inline-more", inline)]
fn clone(&self) -> Self {
ParIter { map: self.map }
}
}

impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clone> fmt::Debug
impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher, A: Allocator + Clone> fmt::Debug
for ParIter<'_, K, V, S, A>
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand All @@ -61,11 +61,11 @@ impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clo
///
/// [`par_keys`]: /hashbrown/struct.HashMap.html#method.par_keys
/// [`HashMap`]: /hashbrown/struct.HashMap.html
pub struct ParKeys<'a, K, V, S, A: AllocRef + Clone> {
pub struct ParKeys<'a, K, V, S, A: Allocator + Clone> {
map: &'a HashMap<K, V, S, A>,
}

impl<'a, K: Sync, V: Sync, S: Sync, A: AllocRef + Clone + Sync> ParallelIterator
impl<'a, K: Sync, V: Sync, S: Sync, A: Allocator + Clone + Sync> ParallelIterator
for ParKeys<'a, K, V, S, A>
{
type Item = &'a K;
Expand All @@ -81,14 +81,14 @@ impl<'a, K: Sync, V: Sync, S: Sync, A: AllocRef + Clone + Sync> ParallelIterator
}
}

impl<K, V, S, A: AllocRef + Clone> Clone for ParKeys<'_, K, V, S, A> {
impl<K, V, S, A: Allocator + Clone> Clone for ParKeys<'_, K, V, S, A> {
#[cfg_attr(feature = "inline-more", inline)]
fn clone(&self) -> Self {
ParKeys { map: self.map }
}
}

impl<K: fmt::Debug + Eq + Hash, V, S: BuildHasher, A: AllocRef + Clone> fmt::Debug
impl<K: fmt::Debug + Eq + Hash, V, S: BuildHasher, A: Allocator + Clone> fmt::Debug
for ParKeys<'_, K, V, S, A>
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand All @@ -103,11 +103,11 @@ impl<K: fmt::Debug + Eq + Hash, V, S: BuildHasher, A: AllocRef + Clone> fmt::Deb
///
/// [`par_values`]: /hashbrown/struct.HashMap.html#method.par_values
/// [`HashMap`]: /hashbrown/struct.HashMap.html
pub struct ParValues<'a, K, V, S, A: AllocRef + Clone = Global> {
pub struct ParValues<'a, K, V, S, A: Allocator + Clone = Global> {
map: &'a HashMap<K, V, S, A>,
}

impl<'a, K: Sync, V: Sync, S: Sync, A: AllocRef + Clone + Sync> ParallelIterator
impl<'a, K: Sync, V: Sync, S: Sync, A: Allocator + Clone + Sync> ParallelIterator
for ParValues<'a, K, V, S, A>
{
type Item = &'a V;
Expand All @@ -123,14 +123,14 @@ impl<'a, K: Sync, V: Sync, S: Sync, A: AllocRef + Clone + Sync> ParallelIterator
}
}

impl<K, V, S, A: AllocRef + Clone> Clone for ParValues<'_, K, V, S, A> {
impl<K, V, S, A: Allocator + Clone> Clone for ParValues<'_, K, V, S, A> {
#[cfg_attr(feature = "inline-more", inline)]
fn clone(&self) -> Self {
ParValues { map: self.map }
}
}

impl<K: Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clone> fmt::Debug
impl<K: Eq + Hash, V: fmt::Debug, S: BuildHasher, A: Allocator + Clone> fmt::Debug
for ParValues<'_, K, V, S, A>
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand All @@ -147,11 +147,11 @@ impl<K: Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clone> fmt::Debu
/// [`par_iter_mut`]: /hashbrown/struct.HashMap.html#method.par_iter_mut
/// [`HashMap`]: /hashbrown/struct.HashMap.html
/// [`IntoParallelRefMutIterator`]: https://docs.rs/rayon/1.0/rayon/iter/trait.IntoParallelRefMutIterator.html
pub struct ParIterMut<'a, K, V, S, A: AllocRef + Clone> {
pub struct ParIterMut<'a, K, V, S, A: Allocator + Clone> {
map: &'a mut HashMap<K, V, S, A>,
}

impl<'a, K: Send + Sync, V: Send, S: Send, A: AllocRef + Clone + Sync> ParallelIterator
impl<'a, K: Send + Sync, V: Send, S: Send, A: Allocator + Clone + Sync> ParallelIterator
for ParIterMut<'a, K, V, S, A>
{
type Item = (&'a K, &'a mut V);
Expand All @@ -170,7 +170,7 @@ impl<'a, K: Send + Sync, V: Send, S: Send, A: AllocRef + Clone + Sync> ParallelI
}
}

impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clone> fmt::Debug
impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher, A: Allocator + Clone> fmt::Debug
for ParIterMut<'_, K, V, S, A>
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand All @@ -185,11 +185,11 @@ impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clo
///
/// [`par_values_mut`]: /hashbrown/struct.HashMap.html#method.par_values_mut
/// [`HashMap`]: /hashbrown/struct.HashMap.html
pub struct ParValuesMut<'a, K, V, S, A: AllocRef + Clone = Global> {
pub struct ParValuesMut<'a, K, V, S, A: Allocator + Clone = Global> {
map: &'a mut HashMap<K, V, S, A>,
}

impl<'a, K: Send, V: Send, S: Send, A: AllocRef + Clone + Send> ParallelIterator
impl<'a, K: Send, V: Send, S: Send, A: Allocator + Clone + Send> ParallelIterator
for ParValuesMut<'a, K, V, S, A>
{
type Item = &'a mut V;
Expand All @@ -205,7 +205,7 @@ impl<'a, K: Send, V: Send, S: Send, A: AllocRef + Clone + Send> ParallelIterator
}
}

impl<K: Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clone> fmt::Debug
impl<K: Eq + Hash, V: fmt::Debug, S: BuildHasher, A: Allocator + Clone> fmt::Debug
for ParValuesMut<'_, K, V, S, A>
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand All @@ -222,11 +222,11 @@ impl<K: Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clone> fmt::Debu
/// [`into_par_iter`]: /hashbrown/struct.HashMap.html#method.into_par_iter
/// [`HashMap`]: /hashbrown/struct.HashMap.html
/// [`IntoParallelIterator`]: https://docs.rs/rayon/1.0/rayon/iter/trait.IntoParallelIterator.html
pub struct IntoParIter<K, V, S, A: AllocRef + Clone = Global> {
pub struct IntoParIter<K, V, S, A: Allocator + Clone = Global> {
map: HashMap<K, V, S, A>,
}

impl<K: Send, V: Send, S: Send, A: AllocRef + Clone + Send> ParallelIterator
impl<K: Send, V: Send, S: Send, A: Allocator + Clone + Send> ParallelIterator
for IntoParIter<K, V, S, A>
{
type Item = (K, V);
Expand All @@ -240,7 +240,7 @@ impl<K: Send, V: Send, S: Send, A: AllocRef + Clone + Send> ParallelIterator
}
}

impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clone> fmt::Debug
impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher, A: Allocator + Clone> fmt::Debug
for IntoParIter<K, V, S, A>
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand All @@ -255,11 +255,11 @@ impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clo
///
/// [`par_drain`]: /hashbrown/struct.HashMap.html#method.par_drain
/// [`HashMap`]: /hashbrown/struct.HashMap.html
pub struct ParDrain<'a, K, V, S, A: AllocRef + Clone = Global> {
pub struct ParDrain<'a, K, V, S, A: Allocator + Clone = Global> {
map: &'a mut HashMap<K, V, S, A>,
}

impl<K: Send, V: Send, S: Send, A: AllocRef + Clone + Sync> ParallelIterator
impl<K: Send, V: Send, S: Send, A: Allocator + Clone + Sync> ParallelIterator
for ParDrain<'_, K, V, S, A>
{
type Item = (K, V);
Expand All @@ -273,15 +273,15 @@ impl<K: Send, V: Send, S: Send, A: AllocRef + Clone + Sync> ParallelIterator
}
}

impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher, A: AllocRef + Clone> fmt::Debug
impl<K: fmt::Debug + Eq + Hash, V: fmt::Debug, S: BuildHasher, A: Allocator + Clone> fmt::Debug
for ParDrain<'_, K, V, S, A>
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.map.iter().fmt(f)
}
}

impl<K: Sync, V: Sync, S: Sync, A: AllocRef + Clone + Sync> HashMap<K, V, S, A> {
impl<K: Sync, V: Sync, S: Sync, A: Allocator + Clone + Sync> HashMap<K, V, S, A> {
/// Visits (potentially in parallel) immutably borrowed keys in an arbitrary order.
#[cfg_attr(feature = "inline-more", inline)]
pub fn par_keys(&self) -> ParKeys<'_, K, V, S, A> {
Expand All @@ -295,7 +295,7 @@ impl<K: Sync, V: Sync, S: Sync, A: AllocRef + Clone + Sync> HashMap<K, V, S, A>
}
}

impl<K: Send, V: Send, S: Send, A: AllocRef + Clone + Sync> HashMap<K, V, S, A> {
impl<K: Send, V: Send, S: Send, A: Allocator + Clone + Sync> HashMap<K, V, S, A> {
/// Visits (potentially in parallel) mutably borrowed values in an arbitrary order.
#[cfg_attr(feature = "inline-more", inline)]
pub fn par_values_mut(&mut self) -> ParValuesMut<'_, K, V, S, A> {
Expand All @@ -315,7 +315,7 @@ where
K: Eq + Hash + Sync,
V: PartialEq + Sync,
S: BuildHasher + Sync,
A: AllocRef + Clone + Sync,
A: Allocator + Clone + Sync,
{
/// Returns `true` if the map is equal to another,
/// i.e. both maps contain the same keys mapped to the same values.
Expand All @@ -329,7 +329,7 @@ where
}
}

impl<K: Send, V: Send, S: Send, A: AllocRef + Clone + Send> IntoParallelIterator
impl<K: Send, V: Send, S: Send, A: Allocator + Clone + Send> IntoParallelIterator
for HashMap<K, V, S, A>
{
type Item = (K, V);
Expand All @@ -341,7 +341,7 @@ impl<K: Send, V: Send, S: Send, A: AllocRef + Clone + Send> IntoParallelIterator
}
}

impl<'a, K: Sync, V: Sync, S: Sync, A: AllocRef + Clone + Sync> IntoParallelIterator
impl<'a, K: Sync, V: Sync, S: Sync, A: Allocator + Clone + Sync> IntoParallelIterator
for &'a HashMap<K, V, S, A>
{
type Item = (&'a K, &'a V);
Expand All @@ -353,7 +353,7 @@ impl<'a, K: Sync, V: Sync, S: Sync, A: AllocRef + Clone + Sync> IntoParallelIter
}
}

impl<'a, K: Send + Sync, V: Send, S: Send, A: AllocRef + Clone + Sync> IntoParallelIterator
impl<'a, K: Send + Sync, V: Send, S: Send, A: Allocator + Clone + Sync> IntoParallelIterator
for &'a mut HashMap<K, V, S, A>
{
type Item = (&'a K, &'a mut V);
Expand Down Expand Up @@ -391,7 +391,7 @@ where
K: Eq + Hash + Send,
V: Send,
S: BuildHasher,
A: AllocRef + Clone,
A: Allocator + Clone,
{
fn par_extend<I>(&mut self, par_iter: I)
where
Expand All @@ -407,7 +407,7 @@ where
K: Copy + Eq + Hash + Sync,
V: Copy + Sync,
S: BuildHasher,
A: AllocRef + Clone,
A: Allocator + Clone,
{
fn par_extend<I>(&mut self, par_iter: I)
where
Expand All @@ -423,7 +423,7 @@ where
K: Eq + Hash,
S: BuildHasher,
I: IntoParallelIterator,
A: AllocRef + Clone,
A: Allocator + Clone,
HashMap<K, V, S, A>: Extend<I::Item>,
{
let (list, len) = super::helpers::collect(par_iter);
Expand Down
16 changes: 8 additions & 8 deletions src/external_trait_impls/rayon/raw.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::raw::Bucket;
use crate::raw::{AllocRef, RawIter, RawIterRange, RawTable};
use crate::raw::{Allocator, RawIter, RawIterRange, RawTable};
use crate::scopeguard::guard;
use alloc::alloc::dealloc;
use core::marker::PhantomData;
Expand Down Expand Up @@ -60,11 +60,11 @@ impl<T> UnindexedProducer for ParIterProducer<T> {
}

/// Parallel iterator which consumes a table and returns elements.
pub struct RawIntoParIter<T, A: AllocRef + Clone> {
pub struct RawIntoParIter<T, A: Allocator + Clone> {
table: RawTable<T, A>,
}

impl<T: Send, A: AllocRef + Clone> ParallelIterator for RawIntoParIter<T, A> {
impl<T: Send, A: Allocator + Clone> ParallelIterator for RawIntoParIter<T, A> {
type Item = T;

#[cfg_attr(feature = "inline-more", inline)]
Expand All @@ -86,16 +86,16 @@ impl<T: Send, A: AllocRef + Clone> ParallelIterator for RawIntoParIter<T, A> {
}

/// Parallel iterator which consumes elements without freeing the table storage.
pub struct RawParDrain<'a, T, A: AllocRef + Clone> {
pub struct RawParDrain<'a, T, A: Allocator + Clone> {
// We don't use a &'a mut RawTable<T> because we want RawParDrain to be
// covariant over T.
table: NonNull<RawTable<T, A>>,
marker: PhantomData<&'a RawTable<T, A>>,
}

unsafe impl<T, A: AllocRef + Clone> Send for RawParDrain<'_, T, A> {}
unsafe impl<T, A: Allocator + Clone> Send for RawParDrain<'_, T, A> {}

impl<T: Send, A: AllocRef + Clone> ParallelIterator for RawParDrain<'_, T, A> {
impl<T: Send, A: Allocator + Clone> ParallelIterator for RawParDrain<'_, T, A> {
type Item = T;

#[cfg_attr(feature = "inline-more", inline)]
Expand All @@ -113,7 +113,7 @@ impl<T: Send, A: AllocRef + Clone> ParallelIterator for RawParDrain<'_, T, A> {
}
}

impl<T, A: AllocRef + Clone> Drop for RawParDrain<'_, T, A> {
impl<T, A: Allocator + Clone> Drop for RawParDrain<'_, T, A> {
fn drop(&mut self) {
// If drive_unindexed is not called then simply clear the table.
unsafe { self.table.as_mut().clear() }
Expand Down Expand Up @@ -172,7 +172,7 @@ impl<T> Drop for ParDrainProducer<T> {
}
}

impl<T, A: AllocRef + Clone> RawTable<T, A> {
impl<T, A: Allocator + Clone> RawTable<T, A> {
/// Returns a parallel iterator over the elements in a `RawTable`.
#[cfg_attr(feature = "inline-more", inline)]
pub unsafe fn par_iter(&self) -> RawParIter<T> {
Expand Down
Loading

0 comments on commit acbedaa

Please sign in to comment.