@@ -23,6 +23,7 @@ use super::raw::bitmask::BitMask;
2323use super :: raw:: imp:: Group ;
2424use super :: scopeguard:: guard;
2525use super :: util:: { cold_path, make_insert_hash} ;
26+ use crate :: sync:: { DynSend , DynSync } ;
2627
2728mod code;
2829mod tests;
@@ -627,7 +628,10 @@ struct DestroyTable<T> {
627628}
628629
629630unsafe impl < T > Sync for DestroyTable < T > { }
630- unsafe impl < T : Send > Send for DestroyTable < T > { }
631+
632+ // FIXME: Unsound
633+ //unsafe impl<T: Send> Send for DestroyTable<T> {}
634+ unsafe impl < T : DynSend > Send for DestroyTable < T > { }
631635
632636impl < T > DestroyTable < T > {
633637 unsafe fn run ( & self ) {
@@ -653,8 +657,9 @@ unsafe impl<#[may_dangle] K, #[may_dangle] V, S> Drop for SyncTable<K, V, S> {
653657 }
654658}
655659
656- unsafe impl < K : Send , V : Send , S : Send > Send for SyncTable < K , V , S > { }
660+ unsafe impl < K : DynSend , V : DynSend , S : DynSend > DynSend for SyncTable < K , V , S > { }
657661unsafe impl < K : Sync , V : Sync , S : Sync > Sync for SyncTable < K , V , S > { }
662+ unsafe impl < K : DynSync , V : DynSync , S : DynSync > DynSync for SyncTable < K , V , S > { }
658663
659664impl < K , V , S : Default > Default for SyncTable < K , V , S > {
660665 #[ inline]
@@ -944,7 +949,7 @@ impl<'a, K, V, S> Write<'a, K, V, S> {
944949 }
945950}
946951
947- impl < ' a , K : Send , V : Send + Clone , S : BuildHasher > Write < ' a , K , V , S > {
952+ impl < ' a , K : DynSend , V : DynSend + Clone , S : BuildHasher > Write < ' a , K , V , S > {
948953 /// Removes an element from the table, and returns a reference to it if was present.
949954 #[ inline]
950955 pub fn remove < Q > ( & mut self , key : & Q , hash : Option < u64 > ) -> Option < ( & ' a K , & ' a V ) >
@@ -970,7 +975,7 @@ impl<'a, K: Send, V: Send + Clone, S: BuildHasher> Write<'a, K, V, S> {
970975 }
971976}
972977
973- impl < ' a , K : Hash + Eq + Send + Clone , V : Send + Clone , S : BuildHasher > Write < ' a , K , V , S > {
978+ impl < ' a , K : Hash + Eq + DynSend + Clone , V : DynSend + Clone , S : BuildHasher > Write < ' a , K , V , S > {
974979 /// Inserts a element into the table.
975980 /// Returns `false` if it already exists and doesn't update the value.
976981 #[ inline]
@@ -995,7 +1000,7 @@ impl<'a, K: Hash + Eq + Send + Clone, V: Send + Clone, S: BuildHasher> Write<'a,
9951000 }
9961001}
9971002
998- impl < ' a , K : Hash + Send + Clone , V : Send + Clone , S : BuildHasher > Write < ' a , K , V , S > {
1003+ impl < ' a , K : Hash + DynSend + Clone , V : DynSend + Clone , S : BuildHasher > Write < ' a , K , V , S > {
9991004 /// Inserts a new element into the table, and returns a reference to it.
10001005 ///
10011006 /// This does not check if the given element already exists in the table.
@@ -1065,7 +1070,7 @@ impl<'a, K: Hash + Send + Clone, V: Send + Clone, S: BuildHasher> Write<'a, K, V
10651070 }
10661071}
10671072
1068- impl < K : Hash + Send , V : Send , S : BuildHasher > Write < ' _ , K , V , S > {
1073+ impl < K : Hash + DynSend , V : DynSend , S : BuildHasher > Write < ' _ , K , V , S > {
10691074 fn replace_table ( & mut self , new_table : TableRef < ( K , V ) > ) {
10701075 let table = self . table . current ( ) ;
10711076
@@ -1111,8 +1116,8 @@ impl<K: Hash + Send, V: Send, S: BuildHasher> Write<'_, K, V, S> {
11111116 }
11121117}
11131118
1114- impl < K : Eq + Hash + Clone + Send , V : Clone + Send , S : BuildHasher + Default > FromIterator < ( K , V ) >
1115- for SyncTable < K , V , S >
1119+ impl < K : Eq + Hash + Clone + DynSend , V : Clone + DynSend , S : BuildHasher + Default >
1120+ FromIterator < ( K , V ) > for SyncTable < K , V , S >
11161121{
11171122 fn from_iter < I : IntoIterator < Item = ( K , V ) > > ( iter : I ) -> Self {
11181123 let iter = iter. into_iter ( ) ;
@@ -1221,7 +1226,7 @@ impl<'a> PotentialSlot<'a> {
12211226 ///
12221227 /// This does not check if the given element already exists in the table.
12231228 #[ inline]
1224- pub fn insert_new < ' b , K : Hash + Send + Clone , V : Send + Clone , S : BuildHasher > (
1229+ pub fn insert_new < ' b , K : Hash + DynSend + Clone , V : DynSend + Clone , S : BuildHasher > (
12251230 self ,
12261231 table : & mut Write < ' b , K , V , S > ,
12271232 key : K ,
@@ -1485,9 +1490,9 @@ impl<T> RawIterRange<T> {
14851490 }
14861491}
14871492
1488- // We make raw iterators unconditionally Send and Sync, and let the PhantomData
1489- // in the actual iterator implementations determine the real Send /Sync bounds.
1490- unsafe impl < T > Send for RawIterRange < T > { }
1493+ // We make raw iterators unconditionally DynSend and Sync, and let the PhantomData
1494+ // in the actual iterator implementations determine the real DynSend /Sync bounds.
1495+ unsafe impl < T > DynSend for RawIterRange < T > { }
14911496unsafe impl < T > Sync for RawIterRange < T > { }
14921497
14931498impl < T > Clone for RawIterRange < T > {
0 commit comments