Skip to content

Commit

Permalink
Add another test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Smith committed Oct 21, 2020
1 parent 0f4abbf commit b3a427d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
15 changes: 15 additions & 0 deletions tests/ui/await_holding_refcell_ref.rs
Expand Up @@ -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;

Expand Down Expand Up @@ -66,6 +80,7 @@ fn main() {
bad(&rc);
bad_mut(&rc);
also_bad(&rc);
less_bad(&rc);
not_good(&rc);
block_bad(&rc);
}
28 changes: 23 additions & 5 deletions tests/ui/await_holding_refcell_ref.stderr
Expand Up @@ -46,32 +46,50 @@ 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
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

0 comments on commit b3a427d

Please sign in to comment.