Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/internal/alloc/dyn_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<usize>() {
match self.iter.next() {
None => core::hint::unreachable_unchecked(),
_ => {}
if self.iter.next().is_none() {
core::hint::unreachable_unchecked()
}
}
Some(result)
Expand Down Expand Up @@ -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::<usize>() {
match self.iter.next() {
None => core::hint::unreachable_unchecked(),
_ => {}
if self.iter.next().is_none() {
core::hint::unreachable_unchecked()
}
}
Some(DynElemMut { value: result })
Expand Down
2 changes: 1 addition & 1 deletion src/internal/gc/quiesce/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/internal/gc/quiesce/synch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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"
);

Expand Down Expand Up @@ -198,7 +197,7 @@ impl<'a> FreezeList<'a> {
}
})
.min()
.unwrap_or(QuiesceEpoch::max_value());
.unwrap_or_else(QuiesceEpoch::max_value);

debug_assert!(
result >= epoch,
Expand Down
6 changes: 3 additions & 3 deletions src/internal/gc/quiesce/synch_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ impl SynchList {
}

#[inline]
pub(super) fn iter<'a>(
&'a self,
) -> impl ExactSizeIterator<Item = &'a Synch> + DoubleEndedIterator<Item = &'a Synch> {
pub(super) fn iter(
&self,
) -> impl ExactSizeIterator<Item = &Synch> + DoubleEndedIterator<Item = &Synch> {
self.synchs.iter().map(|p| unsafe {
// register requires that Synchs aren't moved or dropped until after unregister is
// called
Expand Down
4 changes: 2 additions & 2 deletions src/internal/parking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ 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()
}

#[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 \
Expand Down
4 changes: 2 additions & 2 deletions src/internal/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Pin<'tcell>> {
pub fn try_pin(&self) -> Option<Pin<'_>> {
Pin::try_new(self)
}
}
Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/tcell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,12 @@ where
Tx::Target: Read<'tcell> + Sized,
{
#[inline]
pub fn borrow<'a>(&'a self) -> Result<Ref<'a, T>, Error> {
pub fn borrow(&self) -> Result<Ref<'_, T>, Error> {
self.borrow_ordered(Ordering::default())
}

#[inline]
pub fn borrow_ordered<'a>(&'a self, ordering: Ordering) -> Result<Ref<'a, T>, Error> {
pub fn borrow_ordered(&self, ordering: Ordering) -> Result<Ref<'_, T>, Error> {
self.tcell.borrow(&*self.tx, ordering)
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/thread_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<O, TryReadErr>
where
Expand Down Expand Up @@ -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<O, TryRwErr>
where
Expand Down
19 changes: 10 additions & 9 deletions swym-htm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,33 @@ 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()
}

/// Returns true if the transaction aborted due to running out of capacity.
///
/// 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()
}
}
Expand All @@ -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()
}
}
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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()
}
Expand Down