11use crate :: fx:: { FxHashMap , FxHasher } ;
22#[ cfg( parallel_compiler) ]
33use crate :: sync:: { is_dyn_thread_safe, CacheAligned } ;
4- use crate :: sync:: { Lock , LockGuard } ;
4+ use crate :: sync:: { Assume , Lock , LockGuard } ;
55#[ cfg( parallel_compiler) ]
66use itertools:: Either ;
77use std:: borrow:: Borrow ;
@@ -75,6 +75,7 @@ impl<T> Sharded<T> {
7575
7676 /// The shard is selected by hashing `val` with `FxHasher`.
7777 #[ inline]
78+ #[ track_caller]
7879 pub fn lock_shard_by_value < K : Hash + ?Sized > ( & self , _val : & K ) -> LockGuard < ' _ , T > {
7980 match self {
8081 Self :: Single ( single) => {
@@ -83,19 +84,21 @@ impl<T> Sharded<T> {
8384
8485 // SAFETY: We know `is_dyn_thread_safe` was false when creating the lock thus
8586 // `might_be_dyn_thread_safe` was also false.
86- unsafe { single. lock_assume_no_sync ( ) }
87+ unsafe { single. lock_assume ( Assume :: NoSync ) }
8788 }
8889 #[ cfg( parallel_compiler) ]
8990 Self :: Shards ( ..) => self . lock_shard_by_hash ( make_hash ( _val) ) ,
9091 }
9192 }
9293
9394 #[ inline]
95+ #[ track_caller]
9496 pub fn lock_shard_by_hash ( & self , hash : u64 ) -> LockGuard < ' _ , T > {
9597 self . lock_shard_by_index ( get_shard_hash ( hash) )
9698 }
9799
98100 #[ inline]
101+ #[ track_caller]
99102 pub fn lock_shard_by_index ( & self , _i : usize ) -> LockGuard < ' _ , T > {
100103 match self {
101104 Self :: Single ( single) => {
@@ -104,7 +107,7 @@ impl<T> Sharded<T> {
104107
105108 // SAFETY: We know `is_dyn_thread_safe` was false when creating the lock thus
106109 // `might_be_dyn_thread_safe` was also false.
107- unsafe { single. lock_assume_no_sync ( ) }
110+ unsafe { single. lock_assume ( Assume :: NoSync ) }
108111 }
109112 #[ cfg( parallel_compiler) ]
110113 Self :: Shards ( shards) => {
@@ -115,7 +118,7 @@ impl<T> Sharded<T> {
115118 // always inbounds.
116119 // SAFETY (lock_assume_sync): We know `is_dyn_thread_safe` was true when creating
117120 // the lock thus `might_be_dyn_thread_safe` was also true.
118- unsafe { shards. get_unchecked ( _i & ( SHARDS - 1 ) ) . 0 . lock_assume_sync ( ) }
121+ unsafe { shards. get_unchecked ( _i & ( SHARDS - 1 ) ) . 0 . lock_assume ( Assume :: Sync ) }
119122 }
120123 }
121124 }
0 commit comments