From 21a1054dd406dc38871f14e8b5a75a9bc8562d82 Mon Sep 17 00:00:00 2001 From: Caio Date: Thu, 2 Feb 2023 11:18:18 -0300 Subject: [PATCH 1/2] Mark `MutexGuard` with `#[clippy::has_significant_drop]` `#[clippy::has_significant_drop]` tells that a structure should be considered when evaluating some lints. Examples of such behavior are the existent `clippy::significant_drop_in_scrutinee` and in the soon-to-be-finished https://github.com/rust-lang/rust-clippy/issues/9399. --- src/mutex.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mutex.rs b/src/mutex.rs index 142dc86..aee2d8f 100644 --- a/src/mutex.rs +++ b/src/mutex.rs @@ -536,6 +536,7 @@ impl>> Drop for AcquireSlow { } /// A guard that releases the mutex when dropped. +#[clippy::has_significant_drop] pub struct MutexGuard<'a, T: ?Sized>(&'a Mutex); unsafe impl Send for MutexGuard<'_, T> {} From 0f9507d69151daba3b6623d570f1849bace26ebc Mon Sep 17 00:00:00 2001 From: Caio Date: Fri, 3 Feb 2023 21:41:11 +0000 Subject: [PATCH 2/2] Include more structures --- src/mutex.rs | 1 + src/rwlock.rs | 3 +++ src/semaphore.rs | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/mutex.rs b/src/mutex.rs index aee2d8f..7087dd8 100644 --- a/src/mutex.rs +++ b/src/mutex.rs @@ -596,6 +596,7 @@ impl DerefMut for MutexGuard<'_, T> { } /// An owned guard that releases the mutex when dropped. +#[clippy::has_significant_drop] pub struct MutexGuardArc(Arc>); unsafe impl Send for MutexGuardArc {} diff --git a/src/rwlock.rs b/src/rwlock.rs index 53bc871..a1b9154 100644 --- a/src/rwlock.rs +++ b/src/rwlock.rs @@ -604,6 +604,7 @@ impl<'a, T: ?Sized> Future for Write<'a, T> { } /// A guard that releases the read lock when dropped. +#[clippy::has_significant_drop] pub struct RwLockReadGuard<'a, T: ?Sized>(&'a RwLock); unsafe impl Send for RwLockReadGuard<'_, T> {} @@ -640,6 +641,7 @@ impl Deref for RwLockReadGuard<'_, T> { } /// A guard that releases the upgradable read lock when dropped. +#[clippy::has_significant_drop] pub struct RwLockUpgradableReadGuard<'a, T: ?Sized> { reader: RwLockReadGuard<'a, T>, reserved: MutexGuard<'a, ()>, @@ -851,6 +853,7 @@ impl Drop for RwLockWriteGuardInner<'_, T> { } /// A guard that releases the write lock when dropped. +#[clippy::has_significant_drop] pub struct RwLockWriteGuard<'a, T: ?Sized> { writer: RwLockWriteGuardInner<'a, T>, reserved: MutexGuard<'a, ()>, diff --git a/src/semaphore.rs b/src/semaphore.rs index 4174781..0de4f53 100644 --- a/src/semaphore.rs +++ b/src/semaphore.rs @@ -244,6 +244,7 @@ impl Future for AcquireArc { } /// A guard that releases the acquired permit. +#[clippy::has_significant_drop] #[derive(Debug)] pub struct SemaphoreGuard<'a>(&'a Semaphore); @@ -255,6 +256,7 @@ impl Drop for SemaphoreGuard<'_> { } /// An owned guard that releases the acquired permit. +#[clippy::has_significant_drop] #[derive(Debug)] pub struct SemaphoreGuardArc(Arc);