diff options
Diffstat (limited to 'src/collection')
| -rwxr-xr-x | src/collection/boxed.rs | 6 | ||||
| -rwxr-xr-x | src/collection/ref.rs | 4 | ||||
| -rwxr-xr-x | src/collection/retry.rs | 12 | ||||
| -rwxr-xr-x | src/collection/utils.rs | 8 |
4 files changed, 17 insertions, 13 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<L> BoxedLockCollection<L> { 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<UnsafeCell<L>> = 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<i32>; 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<i32>; 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()), |
