Skip to content

Commit

Permalink
Auto merge of #303 - Amanieu:send_sync, r=Amanieu
Browse files Browse the repository at this point in the history
Fix trait bounds on Send/Sync impls

Fixes #302
  • Loading branch information
bors committed Dec 19, 2021
2 parents 898a9fe + 05ee33e commit 5590aeb
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/external_trait_impls/rayon/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<T, A: Allocator + Clone> RawIntoParIter<T, A> {
}
}

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

#[cfg_attr(feature = "inline-more", inline)]
Expand Down Expand Up @@ -116,7 +116,7 @@ pub struct RawParDrain<'a, T, A: Allocator + Clone = Global> {
marker: PhantomData<&'a RawTable<T, A>>,
}

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

impl<T, A: Allocator + Clone> RawParDrain<'_, T, A> {
#[cfg_attr(feature = "inline-more", inline)]
Expand Down
4 changes: 3 additions & 1 deletion src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2153,14 +2153,16 @@ unsafe impl<K, V, S, A> Send for RawOccupiedEntryMut<'_, K, V, S, A>
where
K: Send,
V: Send,
S: Send,
A: Send + Allocator + Clone,
{
}
unsafe impl<K, V, S, A> Sync for RawOccupiedEntryMut<'_, K, V, S, A>
where
K: Sync,
V: Sync,
A: Send + Allocator + Clone,
S: Sync,
A: Sync + Allocator + Clone,
{
}

Expand Down
42 changes: 36 additions & 6 deletions src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1031,8 +1031,18 @@ impl<T, A: Allocator + Clone> RawTable<T, A> {
}
}

unsafe impl<T, A: Allocator + Clone> Send for RawTable<T, A> where T: Send {}
unsafe impl<T, A: Allocator + Clone> Sync for RawTable<T, A> where T: Sync {}
unsafe impl<T, A: Allocator + Clone> Send for RawTable<T, A>
where
T: Send,
A: Send,
{
}
unsafe impl<T, A: Allocator + Clone> Sync for RawTable<T, A>
where
T: Sync,
A: Sync,
{
}

impl<A> RawTableInner<A> {
#[inline]
Expand Down Expand Up @@ -2156,8 +2166,18 @@ impl<T, A: Allocator + Clone> RawIntoIter<T, A> {
}
}

unsafe impl<T, A: Allocator + Clone> Send for RawIntoIter<T, A> where T: Send {}
unsafe impl<T, A: Allocator + Clone> Sync for RawIntoIter<T, A> where T: Sync {}
unsafe impl<T, A: Allocator + Clone> Send for RawIntoIter<T, A>
where
T: Send,
A: Send,
{
}
unsafe impl<T, A: Allocator + Clone> Sync for RawIntoIter<T, A>
where
T: Sync,
A: Sync,
{
}

#[cfg(feature = "nightly")]
unsafe impl<#[may_dangle] T, A: Allocator + Clone> Drop for RawIntoIter<T, A> {
Expand Down Expand Up @@ -2229,8 +2249,18 @@ impl<T, A: Allocator + Clone> RawDrain<'_, T, A> {
}
}

unsafe impl<T, A: Allocator + Copy> Send for RawDrain<'_, T, A> where T: Send {}
unsafe impl<T, A: Allocator + Copy> Sync for RawDrain<'_, T, A> where T: Sync {}
unsafe impl<T, A: Allocator + Copy> Send for RawDrain<'_, T, A>
where
T: Send,
A: Send,
{
}
unsafe impl<T, A: Allocator + Copy> Sync for RawDrain<'_, T, A>
where
T: Sync,
A: Sync,
{
}

impl<T, A: Allocator + Clone> Drop for RawDrain<'_, T, A> {
#[cfg_attr(feature = "inline-more", inline)]
Expand Down

0 comments on commit 5590aeb

Please sign in to comment.