Skip to content

Commit d855f71

Browse files
committed
Assert Send/Sync/Unpin for all public types in lock module
1 parent 431ca70 commit d855f71

File tree

1 file changed

+72
-2
lines changed

1 file changed

+72
-2
lines changed

futures/tests/auto_traits.rs

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,78 @@ pub mod io {
870870

871871
/// Assert Send/Sync/Unpin for all public types in `futures::lock`.
872872
pub mod lock {
873-
// use super::*;
874-
// use futures::lock::*;
873+
use super::*;
874+
use futures::lock::*;
875+
876+
#[cfg(feature = "bilock")]
877+
assert_impl!(BiLock<()>: Send);
878+
#[cfg(feature = "bilock")]
879+
assert_impl!(BiLock<()>: Sync);
880+
#[cfg(feature = "bilock")]
881+
assert_impl!(BiLock<PhantomPinned>: Unpin);
882+
#[cfg(feature = "bilock")]
883+
assert_not_impl!(BiLock<*const ()>: Send);
884+
#[cfg(feature = "bilock")]
885+
assert_not_impl!(BiLock<*const ()>: Sync);
886+
887+
#[cfg(feature = "bilock")]
888+
assert_impl!(BiLockAcquire<'_, ()>: Send);
889+
#[cfg(feature = "bilock")]
890+
assert_impl!(BiLockAcquire<'_, ()>: Sync);
891+
#[cfg(feature = "bilock")]
892+
assert_impl!(BiLockAcquire<'_, PhantomPinned>: Unpin);
893+
#[cfg(feature = "bilock")]
894+
assert_not_impl!(BiLockAcquire<'_, *const ()>: Send);
895+
#[cfg(feature = "bilock")]
896+
assert_not_impl!(BiLockAcquire<'_, *const ()>: Sync);
897+
898+
#[cfg(feature = "bilock")]
899+
assert_impl!(BiLockGuard<'_, ()>: Send);
900+
#[cfg(feature = "bilock")]
901+
assert_impl!(BiLockGuard<'_, ()>: Sync);
902+
#[cfg(feature = "bilock")]
903+
assert_impl!(BiLockGuard<'_, PhantomPinned>: Unpin);
904+
#[cfg(feature = "bilock")]
905+
assert_not_impl!(BiLockGuard<'_, *const ()>: Send);
906+
#[cfg(feature = "bilock")]
907+
assert_not_impl!(BiLockGuard<'_, *const ()>: Sync);
908+
909+
assert_impl!(MappedMutexGuard<'_, (), ()>: Send);
910+
assert_impl!(MappedMutexGuard<'_, (), ()>: Sync);
911+
assert_impl!(MappedMutexGuard<'_, PhantomPinned, PhantomPinned>: Unpin);
912+
assert_not_impl!(MappedMutexGuard<'_, (), *const ()>: Send);
913+
assert_not_impl!(MappedMutexGuard<'_, *const (), ()>: Send);
914+
assert_not_impl!(MappedMutexGuard<'_, (), *const ()>: Send);
915+
assert_not_impl!(MappedMutexGuard<'_, *const (), ()>: Send);
916+
917+
assert_impl!(Mutex<()>: Send);
918+
assert_impl!(Mutex<()>: Sync);
919+
assert_impl!(Mutex<()>: Unpin);
920+
assert_not_impl!(Mutex<*const ()>: Send);
921+
assert_not_impl!(Mutex<*const ()>: Send);
922+
assert_not_impl!(Mutex<PhantomPinned>: Unpin);
923+
924+
assert_impl!(MutexGuard<'_, ()>: Send);
925+
assert_impl!(MutexGuard<'_, ()>: Sync);
926+
assert_impl!(MutexGuard<'_, PhantomPinned>: Unpin);
927+
assert_not_impl!(MutexGuard<'_, *const ()>: Send);
928+
assert_not_impl!(MutexGuard<'_, *const ()>: Send);
929+
930+
assert_impl!(MutexLockFuture<'_, ()>: Send);
931+
assert_impl!(MutexLockFuture<'_, *const ()>: Sync);
932+
assert_impl!(MutexLockFuture<'_, PhantomPinned>: Unpin);
933+
assert_not_impl!(MutexLockFuture<'_, *const ()>: Send);
934+
935+
#[cfg(feature = "bilock")]
936+
assert_impl!(ReuniteError<()>: Send);
937+
#[cfg(feature = "bilock")]
938+
assert_impl!(ReuniteError<()>: Sync);
939+
#[cfg(feature = "bilock")]
940+
assert_impl!(ReuniteError<PhantomPinned>: Unpin);
941+
#[cfg(feature = "bilock")]
942+
assert_not_impl!(ReuniteError<*const ()>: Send);
943+
#[cfg(feature = "bilock")]
944+
assert_not_impl!(ReuniteError<*const ()>: Sync);
875945
}
876946

877947
/// Assert Send/Sync/Unpin for all public types in `futures::sink`.

0 commit comments

Comments
 (0)