diff --git a/src/internal/alloc/dyn_vec.rs b/src/internal/alloc/dyn_vec.rs index 6a0556a..bf47e09 100644 --- a/src/internal/alloc/dyn_vec.rs +++ b/src/internal/alloc/dyn_vec.rs @@ -314,9 +314,8 @@ impl<'a, T: ?Sized> Iterator for Iter<'a, T> { "invalid size detected for dyn T" ); for _ in 0..size / mem::size_of::() { - match self.iter.next() { - None => core::hint::unreachable_unchecked(), - _ => {} + if self.iter.next().is_none() { + core::hint::unreachable_unchecked() } } Some(result) @@ -353,9 +352,8 @@ impl<'a, T: ?Sized> Iterator for IterMut<'a, T> { "invalid size detected for dyn T" ); for _ in 0..size / mem::size_of::() { - match self.iter.next() { - None => core::hint::unreachable_unchecked(), - _ => {} + if self.iter.next().is_none() { + core::hint::unreachable_unchecked() } } Some(DynElemMut { value: result }) diff --git a/src/internal/gc/quiesce/global.rs b/src/internal/gc/quiesce/global.rs index b6c0811..1046755 100644 --- a/src/internal/gc/quiesce/global.rs +++ b/src/internal/gc/quiesce/global.rs @@ -60,7 +60,7 @@ impl GlobalSynchList { /// Gets write access to the GlobalSynchList. #[inline] - pub fn write<'a>(&'a self) -> Write<'a> { + pub fn write(&self) -> Write<'_> { Write::new(self) } } diff --git a/src/internal/gc/quiesce/synch.rs b/src/internal/gc/quiesce/synch.rs index 367de69..aff2b7b 100644 --- a/src/internal/gc/quiesce/synch.rs +++ b/src/internal/gc/quiesce/synch.rs @@ -109,7 +109,7 @@ impl OwnedSynch { /// /// Requires that self is registered to the GlobalThreadList #[inline] - pub unsafe fn freeze_list<'a>(&'a self) -> FreezeList<'a> { + pub unsafe fn freeze_list(&self) -> FreezeList<'_> { FreezeList::new(self) } @@ -156,8 +156,7 @@ impl<'a> FreezeList<'a> { GlobalSynchList::instance() .raw() .iter() - .find(|&lhs| ptr::eq(lhs, &synch.inner)) - .is_some(), + .any(|lhs| ptr::eq(lhs, &synch.inner)), "bug: synch not registered to the GlobalSynchList" ); @@ -198,7 +197,7 @@ impl<'a> FreezeList<'a> { } }) .min() - .unwrap_or(QuiesceEpoch::max_value()); + .unwrap_or_else(QuiesceEpoch::max_value); debug_assert!( result >= epoch, diff --git a/src/internal/gc/quiesce/synch_list.rs b/src/internal/gc/quiesce/synch_list.rs index db55d54..6e75098 100644 --- a/src/internal/gc/quiesce/synch_list.rs +++ b/src/internal/gc/quiesce/synch_list.rs @@ -39,9 +39,9 @@ impl SynchList { } #[inline] - pub(super) fn iter<'a>( - &'a self, - ) -> impl ExactSizeIterator + DoubleEndedIterator { + pub(super) fn iter( + &self, + ) -> impl ExactSizeIterator + DoubleEndedIterator { self.synchs.iter().map(|p| unsafe { // register requires that Synchs aren't moved or dropped until after unregister is // called diff --git a/src/internal/parking.rs b/src/internal/parking.rs index 6c102cf..4a47643 100644 --- a/src/internal/parking.rs +++ b/src/internal/parking.rs @@ -17,7 +17,7 @@ fn key() -> usize { &EPOCH_CLOCK as *const EpochClock as usize } -fn parkable<'tx, 'tcell>(pin: PinMutRef<'tx, 'tcell>) -> bool { +fn parkable(pin: PinMutRef<'_, '_>) -> bool { let logs = pin.logs(); // parking a thread without any logs, will sleep the thread forever! !logs.read_log.is_empty() || !logs.write_log.is_empty() @@ -25,7 +25,7 @@ fn parkable<'tx, 'tcell>(pin: PinMutRef<'tx, 'tcell>) -> bool { #[inline(never)] #[cold] -pub fn park<'tx, 'tcell>(mut pin: PinRw<'tx, 'tcell>) { +pub fn park(mut pin: PinRw<'_, '_>) { debug_assert!( parkable(pin.reborrow()), "`AWAIT_RETRY` on a transaction that has an empty read set causes the thread to sleep \ diff --git a/src/internal/thread.rs b/src/internal/thread.rs index d328e80..ea62525 100644 --- a/src/internal/thread.rs +++ b/src/internal/thread.rs @@ -69,7 +69,7 @@ impl Thread { /// /// This makes mutable access to `Logs` safe, and is the only way to perform transactions. #[inline] - pub fn try_pin<'tcell>(&'tcell self) -> Option> { + pub fn try_pin(&self) -> Option> { Pin::try_new(self) } } @@ -85,7 +85,7 @@ impl PhoenixTarget for Thread { fn unsubscribe(&mut self) { unsafe { // All thread garbage must be collected before the Thread is dropped. - (&mut *self.logs.get()) + (*self.logs.get()) .garbage .synch_and_collect_all(&self.synch); } diff --git a/src/tcell.rs b/src/tcell.rs index 5c2c80b..1a6a32c 100644 --- a/src/tcell.rs +++ b/src/tcell.rs @@ -430,12 +430,12 @@ where Tx::Target: Read<'tcell> + Sized, { #[inline] - pub fn borrow<'a>(&'a self) -> Result, Error> { + pub fn borrow(&self) -> Result, Error> { self.borrow_ordered(Ordering::default()) } #[inline] - pub fn borrow_ordered<'a>(&'a self, ordering: Ordering) -> Result, Error> { + pub fn borrow_ordered(&self, ordering: Ordering) -> Result, Error> { self.tcell.borrow(&*self.tx, ordering) } } diff --git a/src/thread_key.rs b/src/thread_key.rs index c1d14cc..79f3f93 100644 --- a/src/thread_key.rs +++ b/src/thread_key.rs @@ -106,6 +106,7 @@ impl ThreadKey { /// .unwrap(); /// assert_eq!(x_clone, "not gonna be overwritten"); /// ``` + #[allow(clippy::redundant_closure)] #[inline] pub fn try_read<'tcell, F, O>(&'tcell self, f: F) -> Result where @@ -142,6 +143,7 @@ impl ThreadKey { /// .unwrap(); /// assert_eq!(prev_x, "gonna be overwritten"); /// ``` + #[allow(clippy::redundant_closure)] #[inline] pub fn try_rw<'tcell, F, O>(&'tcell self, f: F) -> Result where diff --git a/swym-htm/src/lib.rs b/swym-htm/src/lib.rs index fdf236e..38e21f8 100644 --- a/swym-htm/src/lib.rs +++ b/swym-htm/src/lib.rs @@ -83,25 +83,25 @@ pub struct BeginCode(back::BeginCode); impl BeginCode { /// Returns true if the `BeginCode` represents a successfully started transaction. #[inline] - pub fn is_started(&self) -> bool { + pub fn is_started(self) -> bool { self.0.is_started() } /// Returns true if the `BeginCode` represents a transaction that was explicitly `abort`ed. #[inline] - pub fn is_explicit_abort(&self) -> bool { + pub fn is_explicit_abort(self) -> bool { self.0.is_explicit_abort() } /// Returns true if retrying the hardware transaction is suggested. #[inline] - pub fn is_retry(&self) -> bool { + pub fn is_retry(self) -> bool { self.0.is_retry() } /// Returns true if the transaction aborted due to a memory conflict. #[inline] - pub fn is_conflict(&self) -> bool { + pub fn is_conflict(self) -> bool { self.0.is_conflict() } @@ -109,7 +109,7 @@ impl BeginCode { /// /// Hardware transactions are typically bounded by L1 cache sizes. #[inline] - pub fn is_capacity(&self) -> bool { + pub fn is_capacity(self) -> bool { self.0.is_capacity() } } @@ -122,13 +122,13 @@ pub struct TestCode(back::TestCode); impl TestCode { /// Returns true if the current thread is in a hardware transaction. #[inline] - pub fn in_transaction(&self) -> bool { + pub fn in_transaction(self) -> bool { self.0.in_transaction() } /// Returns true if the current thread is in a suspended hardware transaction. #[inline] - pub fn is_suspended(&self) -> bool { + pub fn is_suspended(self) -> bool { self.0.is_suspended() } } @@ -172,9 +172,9 @@ impl HardwareTx { ); let b = begin(); if nudge::likely(b.is_started()) { - return Ok(HardwareTx { + Ok(HardwareTx { _private: PhantomData, - }); + }) } else { #[inline(never)] #[cold] @@ -263,6 +263,7 @@ impl HtmUsize { /// This is unsafe because AtomicUsize already allows mutation through immutable reference. /// Therefore, the returned mutable reference cannot escape this module. #[inline(always)] + #[allow(clippy::mut_from_ref)] unsafe fn as_raw(&self, _: &HardwareTx) -> &mut AtomicUsize { &mut *self.inner.get() }