mirror of
https://github.com/bertptrs/tracing-mutex.git
synced 2025-12-25 12:40:31 +01:00
Fix clippy issues
This commit is contained in:
@@ -105,7 +105,7 @@ thread_local! {
|
|||||||
///
|
///
|
||||||
/// Assuming that locks are roughly released in the reverse order in which they were acquired,
|
/// 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.
|
/// 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
|
/// 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,
|
/// 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.
|
/// 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) {
|
fn drop(&mut self) {
|
||||||
// Safety: the only way to get a BorrowedMutex is by locking the mutex.
|
// Safety: the only way to get a BorrowedMutex is by locking the mutex.
|
||||||
unsafe { self.id.mark_released() };
|
unsafe { self.id.mark_released() };
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ unsafe impl<T> RawMutex for TracingWrapper<T>
|
|||||||
where
|
where
|
||||||
T: RawMutex,
|
T: RawMutex,
|
||||||
{
|
{
|
||||||
|
// Known issue with legacy initialisers, allow
|
||||||
|
#[allow(clippy::declare_interior_mutable_const)]
|
||||||
const INIT: Self = Self {
|
const INIT: Self = Self {
|
||||||
inner: T::INIT,
|
inner: T::INIT,
|
||||||
id: LazyMutexId::new(),
|
id: LazyMutexId::new(),
|
||||||
@@ -154,6 +156,8 @@ unsafe impl<T> RawRwLock for TracingWrapper<T>
|
|||||||
where
|
where
|
||||||
T: RawRwLock,
|
T: RawRwLock,
|
||||||
{
|
{
|
||||||
|
// Known issue with legacy initialisers, allow
|
||||||
|
#[allow(clippy::declare_interior_mutable_const)]
|
||||||
const INIT: Self = Self {
|
const INIT: Self = Self {
|
||||||
inner: T::INIT,
|
inner: T::INIT,
|
||||||
id: LazyMutexId::new(),
|
id: LazyMutexId::new(),
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ pub mod tracing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T> Deref for MutexGuard<'a, T> {
|
impl<T> Deref for MutexGuard<'_, T> {
|
||||||
type Target = T;
|
type Target = T;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
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 {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
&mut self.inner
|
&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 {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
self.inner.fmt(f)
|
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
|
where
|
||||||
L: Deref<Target = T>,
|
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
|
where
|
||||||
L: Deref<Target = T> + DerefMut,
|
L: Deref<Target = T> + DerefMut,
|
||||||
{
|
{
|
||||||
@@ -439,6 +439,8 @@ pub mod tracing {
|
|||||||
mutex_id: LazyMutexId,
|
mutex_id: LazyMutexId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New without default is intentional, `std::sync::Once` doesn't implement it either
|
||||||
|
#[allow(clippy::new_without_default)]
|
||||||
impl Once {
|
impl Once {
|
||||||
/// Create a new `Once` value.
|
/// Create a new `Once` value.
|
||||||
pub const fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
|
|||||||
Reference in New Issue
Block a user