2 #![warn(clippy::await_holding_lock)]
6 async fn bad(x: &Mutex<u32>) -> u32 {
7 let guard = x.lock().unwrap();
11 async fn good(x: &Mutex<u32>) -> u32 {
13 let guard = x.lock().unwrap();
17 let guard = x.lock().unwrap();
21 async fn baz() -> u32 {
25 async fn also_bad(x: &Mutex<u32>) -> u32 {
26 let first = baz().await;
28 let guard = x.lock().unwrap();
30 let second = baz().await;
32 let third = baz().await;
34 first + second + third
37 async fn not_good(x: &Mutex<u32>) -> u32 {
38 let first = baz().await;
41 let guard = x.lock().unwrap();
45 let third = baz().await;
47 first + second + third
50 #[allow(clippy::manual_async_fn)]
51 fn block_bad(x: &Mutex<u32>) -> impl std::future::Future<Output = u32> + '_ {
53 let guard = x.lock().unwrap();
59 let m = Mutex::new(100);