diff --git a/framework/jinux-frame/src/sync/mutex.rs b/framework/jinux-frame/src/sync/mutex.rs index ab043bb57..1e64144d5 100644 --- a/framework/jinux-frame/src/sync/mutex.rs +++ b/framework/jinux-frame/src/sync/mutex.rs @@ -33,11 +33,7 @@ impl Mutex { pub fn try_lock(&self) -> Option> { // Cannot be reduced to `then_some`, or the possible dropping of the temporary // guard will cause an unexpected unlock. - // - // TODO: Remove the lint suppression when the false positive warning is fixed - // upstream. - #[allow(clippy::unnecessary_lazy_evaluations)] - self.acquire_lock().then(|| MutexGuard { mutex: self }) + self.acquire_lock().then(|| MutexGuard::new(self)) } /// Release the mutex and wake up one thread which is blocked on this mutex. @@ -66,10 +62,17 @@ impl fmt::Debug for Mutex { unsafe impl Send for Mutex {} unsafe impl Sync for Mutex {} +#[clippy::has_significant_drop] pub struct MutexGuard<'a, T> { mutex: &'a Mutex, } +impl<'a, T> MutexGuard<'a, T> { + fn new(mutex: &'a Mutex) -> MutexGuard<'a, T> { + MutexGuard { mutex } + } +} + impl<'a, T> Deref for MutexGuard<'a, T> { type Target = T;