1 #![warn(clippy::await_holding_refcell_ref)]
3 use std::cell::RefCell;
5 async fn bad(x: &RefCell<u32>) -> u32 {
10 async fn bad_mut(x: &RefCell<u32>) -> u32 {
11 let b = x.borrow_mut();
15 async fn good(x: &RefCell<u32>) -> u32 {
17 let b = x.borrow_mut();
21 let b = x.borrow_mut();
25 async fn baz() -> u32 {
29 async fn also_bad(x: &RefCell<u32>) -> u32 {
30 let first = baz().await;
32 let b = x.borrow_mut();
34 let second = baz().await;
36 let third = baz().await;
38 first + second + third
41 async fn less_bad(x: &RefCell<u32>) -> u32 {
42 let first = baz().await;
44 let b = x.borrow_mut();
46 let second = baz().await;
50 let third = baz().await;
52 first + second + third
55 async fn not_good(x: &RefCell<u32>) -> u32 {
56 let first = baz().await;
59 let b = x.borrow_mut();
63 let third = baz().await;
65 first + second + third
68 #[allow(clippy::manual_async_fn)]
69 fn block_bad(x: &RefCell<u32>) -> impl std::future::Future<Output = u32> + '_ {
71 let b = x.borrow_mut();
77 let rc = RefCell::new(100);