1 #![warn(clippy::await_holding_lock)]
5 async fn bad(x: &Mutex<u32>) -> u32 {
6 let guard = x.lock().unwrap();
10 async fn good(x: &Mutex<u32>) -> u32 {
12 let guard = x.lock().unwrap();
16 let guard = x.lock().unwrap();
20 async fn baz() -> u32 {
24 async fn also_bad(x: &Mutex<u32>) -> u32 {
25 let first = baz().await;
27 let guard = x.lock().unwrap();
29 let second = baz().await;
31 let third = baz().await;
33 first + second + third
36 async fn not_good(x: &Mutex<u32>) -> u32 {
37 let first = baz().await;
40 let guard = x.lock().unwrap();
44 let third = baz().await;
46 first + second + third
49 #[allow(clippy::manual_async_fn)]
50 fn block_bad(x: &Mutex<u32>) -> impl std::future::Future<Output = u32> + '_ {
52 let guard = x.lock().unwrap();
58 let m = Mutex::new(100);