about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/await_holding_refcell_ref.rs15
-rw-r--r--tests/ui/await_holding_refcell_ref.stderr28
2 files changed, 38 insertions, 5 deletions
diff --git a/tests/ui/await_holding_refcell_ref.rs b/tests/ui/await_holding_refcell_ref.rs
index dd3adc494f1..88841597bb6 100644
--- a/tests/ui/await_holding_refcell_ref.rs
+++ b/tests/ui/await_holding_refcell_ref.rs
@@ -39,6 +39,20 @@ async fn also_bad(x: &RefCell<u32>) -> u32 {
     first + second + third
 }
 
+async fn less_bad(x: &RefCell<u32>) -> u32 {
+    let first = baz().await;
+
+    let b = x.borrow_mut();
+
+    let second = baz().await;
+
+    drop(b);
+
+    let third = baz().await;
+
+    first + second + third
+}
+
 async fn not_good(x: &RefCell<u32>) -> u32 {
     let first = baz().await;
 
@@ -66,6 +80,7 @@ fn main() {
     bad(&rc);
     bad_mut(&rc);
     also_bad(&rc);
+    less_bad(&rc);
     not_good(&rc);
     block_bad(&rc);
 }
diff --git a/tests/ui/await_holding_refcell_ref.stderr b/tests/ui/await_holding_refcell_ref.stderr
index b114945504a..b504f045491 100644
--- a/tests/ui/await_holding_refcell_ref.stderr
+++ b/tests/ui/await_holding_refcell_ref.stderr
@@ -46,13 +46,31 @@ LL | | }
    | |_^
 
 error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await.
-  --> $DIR/await_holding_refcell_ref.rs:46:13
+  --> $DIR/await_holding_refcell_ref.rs:45:9
+   |
+LL |     let b = x.borrow_mut();
+   |         ^
+   |
+note: these are all the await points this ref is held through
+  --> $DIR/await_holding_refcell_ref.rs:45:5
+   |
+LL | /     let b = x.borrow_mut();
+LL | |
+LL | |     let second = baz().await;
+LL | |
+...  |
+LL | |     first + second + third
+LL | | }
+   | |_^
+
+error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await.
+  --> $DIR/await_holding_refcell_ref.rs:60:13
    |
 LL |         let b = x.borrow_mut();
    |             ^
    |
 note: these are all the await points this ref is held through
-  --> $DIR/await_holding_refcell_ref.rs:46:9
+  --> $DIR/await_holding_refcell_ref.rs:60:9
    |
 LL | /         let b = x.borrow_mut();
 LL | |         baz().await
@@ -60,18 +78,18 @@ LL | |     };
    | |_____^
 
 error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await.
-  --> $DIR/await_holding_refcell_ref.rs:58:13
+  --> $DIR/await_holding_refcell_ref.rs:72:13
    |
 LL |         let b = x.borrow_mut();
    |             ^
    |
 note: these are all the await points this ref is held through
-  --> $DIR/await_holding_refcell_ref.rs:58:9
+  --> $DIR/await_holding_refcell_ref.rs:72:9
    |
 LL | /         let b = x.borrow_mut();
 LL | |         baz().await
 LL | |     }
    | |_____^
 
-error: aborting due to 5 previous errors
+error: aborting due to 6 previous errors