From 8130b6a8c50777c852ee3e8baa076c0f2a3baedb Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Sat, 18 Jan 2025 11:50:52 +0100 Subject: [PATCH] Fix clippy issues --- src/lib.rs | 4 ++-- src/stdsync.rs | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 56b7355..1a5c46a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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> = RefCell::new(Vec::new()); + static HELD_LOCKS: RefCell> = const { RefCell::new(Vec::new()) }; } /// Dedicated ID type for Mutexes @@ -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() }; diff --git a/src/stdsync.rs b/src/stdsync.rs index c3ba067..7d16b68 100644 --- a/src/stdsync.rs +++ b/src/stdsync.rs @@ -161,7 +161,7 @@ pub mod tracing { } } - impl<'a, T> Deref for MutexGuard<'a, T> { + impl Deref for MutexGuard<'_, T> { type Target = T; fn deref(&self) -> &Self::Target { @@ -169,13 +169,13 @@ pub mod tracing { } } - impl<'a, T> DerefMut for MutexGuard<'a, T> { + impl 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 fmt::Display for MutexGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.inner.fmt(f) } @@ -409,7 +409,7 @@ pub mod tracing { } } - impl<'a, L, T> Deref for TracingRwLockGuard<'a, L> + impl Deref for TracingRwLockGuard<'_, L> where L: Deref, { @@ -420,7 +420,7 @@ pub mod tracing { } } - impl<'a, T, L> DerefMut for TracingRwLockGuard<'a, L> + impl DerefMut for TracingRwLockGuard<'_, L> where L: Deref + DerefMut, { @@ -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 {