mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
Add another test case
This commit is contained in:
parent
0f4abbf99a
commit
b3a427d873
2 changed files with 38 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue