Skip to content

Commit

Permalink
Fix clippy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bertptrs committed Jan 18, 2025
1 parent 1a05708 commit 8130b6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ thread_local! {
///
/// Assuming that locks are roughly released in the reverse order in which they were acquired,
/// a stack should be more efficient to keep track of the current state than a set would be.
static HELD_LOCKS: RefCell<Vec<usize>> = RefCell::new(Vec::new());
static HELD_LOCKS: RefCell<Vec<usize>> = const { RefCell::new(Vec::new()) };
}

/// Dedicated ID type for Mutexes
Expand Down Expand Up @@ -275,7 +275,7 @@ struct BorrowedMutex<'a> {
///
/// This function panics if the lock did not appear to be handled by this thread. If that happens,
/// that is an indication of a serious design flaw in this library.
impl<'a> Drop for BorrowedMutex<'a> {
impl Drop for BorrowedMutex<'_> {
fn drop(&mut self) {
// Safety: the only way to get a BorrowedMutex is by locking the mutex.
unsafe { self.id.mark_released() };
Expand Down
12 changes: 7 additions & 5 deletions src/stdsync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,21 @@ pub mod tracing {
}
}

impl<'a, T> Deref for MutexGuard<'a, T> {
impl<T> Deref for MutexGuard<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
&self.inner
}
}

impl<'a, T> DerefMut for MutexGuard<'a, T> {
impl<T> DerefMut for MutexGuard<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}

impl<'a, T: fmt::Display> fmt::Display for MutexGuard<'a, T> {
impl<T: fmt::Display> fmt::Display for MutexGuard<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.inner.fmt(f)
}
Expand Down Expand Up @@ -409,7 +409,7 @@ pub mod tracing {
}
}

impl<'a, L, T> Deref for TracingRwLockGuard<'a, L>
impl<L, T> Deref for TracingRwLockGuard<'_, L>
where
L: Deref<Target = T>,
{
Expand All @@ -420,7 +420,7 @@ pub mod tracing {
}
}

impl<'a, T, L> DerefMut for TracingRwLockGuard<'a, L>
impl<T, L> DerefMut for TracingRwLockGuard<'_, L>
where
L: Deref<Target = T> + DerefMut,
{
Expand All @@ -439,6 +439,8 @@ pub mod tracing {
mutex_id: LazyMutexId,
}

// New without default is intentional, `std::sync::Once` doesn't implement it either
#[allow(clippy::new_without_default)]
impl Once {
/// Create a new `Once` value.
pub const fn new() -> Self {
Expand Down

0 comments on commit 8130b6a

Please sign in to comment.