From bf11d8039eb72a37e852f5b64c8ee1f241203878 Mon Sep 17 00:00:00 2001 From: Mica White Date: Sat, 7 Feb 2026 10:49:18 -0500 Subject: Fix clippy warnings --- src/collection/boxed.rs | 6 +++--- src/collection/ref.rs | 4 ++-- src/collection/retry.rs | 12 ++++++------ src/collection/utils.rs | 8 ++++++-- src/poisonable.rs | 2 +- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/collection/boxed.rs b/src/collection/boxed.rs index 3600d8e..85ec34f 100755 --- a/src/collection/boxed.rs +++ b/src/collection/boxed.rs @@ -207,7 +207,7 @@ impl BoxedLockCollection { pub fn into_child(mut self) -> L { unsafe { // safety: this collection will never be used again - std::ptr::drop_in_place(&mut self.locks); + std::ptr::drop_in_place(&raw mut self.locks); // safety: this was allocated using a box, and is now unique let boxed: Box> = Box::from_raw(self.child.cast_mut()); // to prevent a double free @@ -911,7 +911,7 @@ mod tests { let mutexes = [Mutex::new(0), Mutex::new(1)]; let collection = BoxedLockCollection::new_ref(&mutexes); - assert!(std::ptr::addr_eq(&mutexes, collection.as_ref())) + assert!(std::ptr::addr_eq(&raw const mutexes, collection.as_ref())) } #[test] @@ -919,6 +919,6 @@ mod tests { let mutexes = [Mutex::new(0), Mutex::new(1)]; let collection = BoxedLockCollection::new_ref(&mutexes); - assert!(std::ptr::addr_eq(&mutexes, *collection.child())) + assert!(std::ptr::addr_eq(&raw const mutexes, *collection.child())) } } diff --git a/src/collection/ref.rs b/src/collection/ref.rs index 4ba06bd..14ad861 100755 --- a/src/collection/ref.rs +++ b/src/collection/ref.rs @@ -756,7 +756,7 @@ mod tests { let mutexes = [Mutex::new(0), Mutex::new(1)]; let collection = RefLockCollection::new(&mutexes); - assert!(std::ptr::addr_eq(&mutexes, collection.as_ref())) + assert!(std::ptr::addr_eq(&raw const mutexes, collection.as_ref())) } #[test] @@ -764,6 +764,6 @@ mod tests { let mutexes = [Mutex::new(0), Mutex::new(1)]; let collection = RefLockCollection::new(&mutexes); - assert!(std::ptr::addr_eq(&mutexes, collection.child())) + assert!(std::ptr::addr_eq(&raw const mutexes, collection.child())) } } diff --git a/src/collection/retry.rs b/src/collection/retry.rs index 64e8ca8..c887405 100755 --- a/src/collection/retry.rs +++ b/src/collection/retry.rs @@ -1150,11 +1150,11 @@ mod tests { let collection: RetryingLockCollection<[RwLock; 0]> = RetryingLockCollection::new([]); let guard = collection.lock(key); - assert!(guard.len() == 0); + assert!(guard.is_empty()); let key = RetryingLockCollection::<[RwLock<_>; 0]>::unlock(guard); let guard = collection.read(key); - assert!(guard.len() == 0); + assert!(guard.is_empty()); } #[test] @@ -1163,11 +1163,11 @@ mod tests { let collection: RetryingLockCollection<[RwLock; 0]> = RetryingLockCollection::new([]); let guard = collection.read(key); - assert!(guard.len() == 0); + assert!(guard.is_empty()); let key = RetryingLockCollection::<[RwLock<_>; 0]>::unlock_read(guard); let guard = collection.lock(key); - assert!(guard.len() == 0); + assert!(guard.is_empty()); } #[test] @@ -1175,7 +1175,7 @@ mod tests { let mutexes = [Mutex::new(0), Mutex::new(1)]; let collection = RetryingLockCollection::new_ref(&mutexes); - assert!(std::ptr::addr_eq(&mutexes, collection.as_ref())) + assert!(std::ptr::addr_eq(&raw const mutexes, collection.as_ref())) } #[test] @@ -1193,7 +1193,7 @@ mod tests { let mutexes = [Mutex::new(0), Mutex::new(1)]; let collection = RetryingLockCollection::new_ref(&mutexes); - assert!(std::ptr::addr_eq(&mutexes, *collection.child())) + assert!(std::ptr::addr_eq(&raw const mutexes, *collection.child())) } #[test] diff --git a/src/collection/utils.rs b/src/collection/utils.rs index 71a023e..e79b78b 100755 --- a/src/collection/utils.rs +++ b/src/collection/utils.rs @@ -227,7 +227,9 @@ pub unsafe fn attempt_to_recover_writes_from_panic(locks: &[&dyn RawLock]) { handle_unwind( || { // safety: the caller assumes that these are already locked - locks.iter().for_each(|lock| lock.raw_unlock_write()); + for lock in locks { + lock.raw_unlock_write(); + } }, // if we get another panic in here, we'll just have to poison what remains || locks.iter().for_each(|l| l.poison()), @@ -239,7 +241,9 @@ pub unsafe fn attempt_to_recover_reads_from_panic(locked: &[&dyn RawLock]) { handle_unwind( || { // safety: the caller assumes these are already locked - locked.iter().for_each(|lock| lock.raw_unlock_read()); + for lock in locked { + lock.raw_unlock_read(); + } }, // if we get another panic in here, we'll just have to poison what remains || locked.iter().for_each(|l| l.poison()), diff --git a/src/poisonable.rs b/src/poisonable.rs index 74444db..ac0e1bf 100755 --- a/src/poisonable.rs +++ b/src/poisonable.rs @@ -469,7 +469,7 @@ mod tests { poisonable.get_ptrs(&mut lock_ptrs); assert_eq!(lock_ptrs.len(), 1); - assert!(std::ptr::addr_eq(lock_ptrs[0], &poisonable.inner)); + assert!(std::ptr::addr_eq(lock_ptrs[0], &raw const poisonable.inner)); } #[test] -- cgit v1.2.3