diff --git a/lock_api/src/lib.rs b/lock_api/src/lib.rs index de724422..d9097a39 100644 --- a/lock_api/src/lib.rs +++ b/lock_api/src/lib.rs @@ -99,6 +99,8 @@ pub struct GuardSend(()); /// Marker type which indicates that the Guard type for a lock is not `Send`. pub struct GuardNoSend(*mut ()); +unsafe impl Sync for GuardNoSend {} + mod mutex; pub use crate::mutex::*; diff --git a/lock_api/src/mutex.rs b/lock_api/src/mutex.rs index e435d8ae..aded96d1 100644 --- a/lock_api/src/mutex.rs +++ b/lock_api/src/mutex.rs @@ -601,7 +601,7 @@ unsafe impl<'a, R: RawMutex + Sync + 'a, T: ?Sized + Sync + 'a> Sync for MappedMutexGuard<'a, R, T> { } -unsafe impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> Send for MappedMutexGuard<'a, R, T> where +unsafe impl<'a, R: RawMutex + 'a, T: ?Sized + Send + 'a> Send for MappedMutexGuard<'a, R, T> where R::GuardMarker: Send { } diff --git a/lock_api/src/rwlock.rs b/lock_api/src/rwlock.rs index a25c2f45..e97de980 100644 --- a/lock_api/src/rwlock.rs +++ b/lock_api/src/rwlock.rs @@ -875,8 +875,6 @@ pub struct RwLockReadGuard<'a, R: RawRwLock, T: ?Sized> { marker: PhantomData<(&'a T, R::GuardMarker)>, } -unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Sync + 'a> Sync for RwLockReadGuard<'a, R, T> {} - impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> RwLockReadGuard<'a, R, T> { /// Returns a reference to the original reader-writer lock object. pub fn rwlock(s: &Self) -> &'a RwLock { @@ -1051,8 +1049,6 @@ pub struct RwLockWriteGuard<'a, R: RawRwLock, T: ?Sized> { marker: PhantomData<(&'a mut T, R::GuardMarker)>, } -unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Sync + 'a> Sync for RwLockWriteGuard<'a, R, T> {} - impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> RwLockWriteGuard<'a, R, T> { /// Returns a reference to the original reader-writer lock object. pub fn rwlock(s: &Self) -> &'a RwLock { @@ -1514,7 +1510,7 @@ pub struct MappedRwLockReadGuard<'a, R: RawRwLock, T: ?Sized> { } unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Sync + 'a> Sync for MappedRwLockReadGuard<'a, R, T> {} -unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Send for MappedRwLockReadGuard<'a, R, T> where +unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Sync + 'a> Send for MappedRwLockReadGuard<'a, R, T> where R::GuardMarker: Send { } @@ -1652,7 +1648,7 @@ unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Sync + 'a> Sync for MappedRwLockWriteGuard<'a, R, T> { } -unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Send for MappedRwLockWriteGuard<'a, R, T> where +unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Send + 'a> Send for MappedRwLockWriteGuard<'a, R, T> where R::GuardMarker: Send { }