diff --git a/src/lock/api.rs b/src/lock/api.rs index 54799f6e6a..31a3d894e7 100644 --- a/src/lock/api.rs +++ b/src/lock/api.rs @@ -173,7 +173,6 @@ impl<'s, L: RawLock, T> LockGuard<'s, L, T> { #[cfg(test)] pub mod tests { - use core::ops::Deref; use std::thread::scope; @@ -193,8 +192,8 @@ pub mod tests { } }); - let mut d = d.lock(); - d.sort(); - assert_eq!(d.deref(), &(1..LENGTH).collect::>()); + let mut d = d.into_inner(); + d.sort_unstable(); + assert_eq!(d, (1..LENGTH).collect::>()); } } diff --git a/src/lock/mcslock.rs b/src/lock/mcslock.rs index 3e98d88f40..df23e523bc 100644 --- a/src/lock/mcslock.rs +++ b/src/lock/mcslock.rs @@ -50,9 +50,7 @@ impl RawLock for McsLock { // SAFETY: `prev` is valid, so is not the initial pointer. Hence, it is a pointer from // `swap()` by another thread's `lock()`, and that thread guarantees that `prev` will not be // freed until this store is complete. - unsafe { - (*prev).next.store(node, Ordering::Release); - } + unsafe { (*prev).next.store(node, Ordering::Release) }; let backoff = Backoff::new(); // SAFETY: `node` was made valid above. Since other threads will not free `node`, it still diff --git a/src/lock/mcsparkinglock.rs b/src/lock/mcsparkinglock.rs index 4b67fbcf25..53acae717f 100644 --- a/src/lock/mcsparkinglock.rs +++ b/src/lock/mcsparkinglock.rs @@ -51,9 +51,7 @@ impl RawLock for McsParkingLock { } // SAFETY: See safety of McsLock::lock(). - unsafe { - (*prev).next.store(node, Ordering::Release); - } + unsafe { (*prev).next.store(node, Ordering::Release) }; // SAFETY: See safety of McsLock::lock(). while unsafe { (*node).locked.load(Ordering::Acquire) } { diff --git a/src/lockfree/list.rs b/src/lockfree/list.rs index f9fef0fd30..d7dd8fb346 100644 --- a/src/lockfree/list.rs +++ b/src/lockfree/list.rs @@ -54,7 +54,7 @@ pub struct Cursor<'g, K, V> { } // Manual implementation as deriving `Clone` leads to unnecessary trait bounds. -impl<'g, K, V> Clone for Cursor<'g, K, V> { +impl Clone for Cursor<'_, K, V> { fn clone(&self) -> Self { Self { prev: self.prev, diff --git a/src/lockfree/queue.rs b/src/lockfree/queue.rs index e18fe8dd5b..6b531b9968 100644 --- a/src/lockfree/queue.rs +++ b/src/lockfree/queue.rs @@ -44,12 +44,14 @@ impl Default for Queue { head: CachePadded::new(Atomic::null()), tail: CachePadded::new(Atomic::null()), }; + + // SAFETY: We are creating a new queue, hence have sole ownership of it. let sentinel = Owned::new(Node { data: MaybeUninit::uninit(), next: Atomic::null(), - }); - // SAFETY: We are creating a new queue, hence have sole ownership of it. - let sentinel = sentinel.into_shared(unsafe { unprotected() }); + }) + .into_shared(unsafe { unprotected() }); + q.head.store(sentinel, Ordering::Relaxed); q.tail.store(sentinel, Ordering::Relaxed); q @@ -67,8 +69,8 @@ impl Queue { let new = Owned::new(Node { data: MaybeUninit::new(t), next: Atomic::null(), - }); - let new = new.into_shared(guard); + }) + .into_shared(guard); loop { // We push onto the tail, so we'll start optimistically by looking there first.