❯❯ cargo clippy
warning: this `MutexGuard` is held across an `await` point
--> src/resource.rs:38:13
|
38 | let mut guard = self.resources.lock();
| ^^^^^^^^^
|
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
note: these are all the `await` points this lock is held through
--> src/resource.rs:59:60
|
59 | guard = self.cond.wait::<MutexGuard<_>>(guard).await;
| ^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#await_holding_lock
= note: `#[warn(clippy::await_holding_lock)]` on by default
warning: `local-ci` (bin "local-ci") generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.04s
I do not expect any warning here because I believe the guard is moved into the future before it is awaited. (The code implementing the future will release the lock, I believe that even if it didn't, that would be a bug in the library and not something for Clippy to warn about here).
Summary
When using this library the warning
this MutexGuard is held across an await point
fires, but I don't believe any mutex is held across awaitLint Name
await_holding_lock
Reproducer
I tried this code:
I saw this happen:
I do not expect any warning here because I believe the guard is moved into the future before it is awaited. (The code implementing the future will release the lock, I believe that even if it didn't, that would be a bug in the library and not something for Clippy to warn about here).
Version
Additional Labels
No response