Skip to content

Commit de83f44

Browse files
author
Daniel Smith
committed
Add another test case
1 parent 839dba7 commit de83f44

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

tests/ui/await_holding_refcell_ref.rs

+15
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@ async fn also_bad(x: &RefCell<u32>) -> u32 {
3939
first + second + third
4040
}
4141

42+
async fn less_bad(x: &RefCell<u32>) -> u32 {
43+
let first = baz().await;
44+
45+
let b = x.borrow_mut();
46+
47+
let second = baz().await;
48+
49+
drop(b);
50+
51+
let third = baz().await;
52+
53+
first + second + third
54+
}
55+
4256
async fn not_good(x: &RefCell<u32>) -> u32 {
4357
let first = baz().await;
4458

@@ -66,6 +80,7 @@ fn main() {
6680
bad(&rc);
6781
bad_mut(&rc);
6882
also_bad(&rc);
83+
less_bad(&rc);
6984
not_good(&rc);
7085
block_bad(&rc);
7186
}

tests/ui/await_holding_refcell_ref.stderr

+23-5
Original file line numberDiff line numberDiff line change
@@ -46,32 +46,50 @@ LL | | }
4646
| |_^
4747

4848
error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await.
49-
--> $DIR/await_holding_refcell_ref.rs:46:13
49+
--> $DIR/await_holding_refcell_ref.rs:45:9
50+
|
51+
LL | let b = x.borrow_mut();
52+
| ^
53+
|
54+
note: these are all the await points this ref is held through
55+
--> $DIR/await_holding_refcell_ref.rs:45:5
56+
|
57+
LL | / let b = x.borrow_mut();
58+
LL | |
59+
LL | | let second = baz().await;
60+
LL | |
61+
... |
62+
LL | | first + second + third
63+
LL | | }
64+
| |_^
65+
66+
error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await.
67+
--> $DIR/await_holding_refcell_ref.rs:60:13
5068
|
5169
LL | let b = x.borrow_mut();
5270
| ^
5371
|
5472
note: these are all the await points this ref is held through
55-
--> $DIR/await_holding_refcell_ref.rs:46:9
73+
--> $DIR/await_holding_refcell_ref.rs:60:9
5674
|
5775
LL | / let b = x.borrow_mut();
5876
LL | | baz().await
5977
LL | | };
6078
| |_____^
6179

6280
error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await.
63-
--> $DIR/await_holding_refcell_ref.rs:58:13
81+
--> $DIR/await_holding_refcell_ref.rs:72:13
6482
|
6583
LL | let b = x.borrow_mut();
6684
| ^
6785
|
6886
note: these are all the await points this ref is held through
69-
--> $DIR/await_holding_refcell_ref.rs:58:9
87+
--> $DIR/await_holding_refcell_ref.rs:72:9
7088
|
7189
LL | / let b = x.borrow_mut();
7290
LL | | baz().await
7391
LL | | }
7492
| |_____^
7593

76-
error: aborting due to 5 previous errors
94+
error: aborting due to 6 previous errors
7795

0 commit comments

Comments
 (0)