diff --git a/framework/jinux-frame/src/sync/mutex.rs b/framework/jinux-frame/src/sync/mutex.rs index 799a5ccc2..ab043bb57 100644 --- a/framework/jinux-frame/src/sync/mutex.rs +++ b/framework/jinux-frame/src/sync/mutex.rs @@ -31,7 +31,13 @@ impl Mutex { /// Try Acquire the mutex immedidately. pub fn try_lock(&self) -> Option> { - self.acquire_lock().then_some(MutexGuard { mutex: self }) + // 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 }) } /// Release the mutex and wake up one thread which is blocked on this mutex.