Fix clippy issues

This commit is contained in:
2025-01-18 11:50:52 +01:00
parent e60dba2c25
commit 40f835afd2
3 changed files with 13 additions and 7 deletions

View File

@@ -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
@@ -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() };

View File

@@ -90,6 +90,8 @@ unsafe impl<T> RawMutex for TracingWrapper<T>
where
T: RawMutex,
{
// Known issue with legacy initialisers, allow
#[allow(clippy::declare_interior_mutable_const)]
const INIT: Self = Self {
inner: T::INIT,
id: LazyMutexId::new(),
@@ -154,6 +156,8 @@ unsafe impl<T> RawRwLock for TracingWrapper<T>
where
T: RawRwLock,
{
// Known issue with legacy initialisers, allow
#[allow(clippy::declare_interior_mutable_const)]
const INIT: Self = Self {
inner: T::INIT,
id: LazyMutexId::new(),

View File

@@ -161,7 +161,7 @@ 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 {
@@ -169,13 +169,13 @@ pub mod tracing {
}
}
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)
}
@@ -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>,
{
@@ -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,
{
@@ -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 {