Update issue-64130-4-async-move.rs
This commit is contained in:
parent
9bcc107ffe
commit
777db102df
3 changed files with 36 additions and 6 deletions
|
|
@ -1,12 +1,12 @@
|
|||
error: future cannot be sent between threads safely
|
||||
--> $DIR/issue-64130-4-async-move.rs:15:17
|
||||
--> $DIR/issue-64130-4-async-move.rs:19:17
|
||||
|
|
||||
LL | pub fn foo() -> impl Future + Send {
|
||||
| ^^^^^^^^^^^^^^^^^^ future created by async block is not `Send`
|
||||
|
|
||||
= help: the trait `Sync` is not implemented for `(dyn Any + Send + 'static)`
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/issue-64130-4-async-move.rs:21:31
|
||||
--> $DIR/issue-64130-4-async-move.rs:25:31
|
||||
|
|
||||
LL | match client.status() {
|
||||
| ------ has type `&Client` which is not `Send`
|
||||
|
|
@ -17,7 +17,7 @@ LL | let _x = get().await;
|
|||
LL | }
|
||||
| - `client` is later dropped here
|
||||
help: consider moving this into a `let` binding to create a shorter lived borrow
|
||||
--> $DIR/issue-64130-4-async-move.rs:19:15
|
||||
--> $DIR/issue-64130-4-async-move.rs:23:15
|
||||
|
|
||||
LL | match client.status() {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
error: future cannot be sent between threads safely
|
||||
--> $DIR/issue-64130-4-async-move.rs:19:17
|
||||
|
|
||||
LL | pub fn foo() -> impl Future + Send {
|
||||
| ^^^^^^^^^^^^^^^^^^ future created by async block is not `Send`
|
||||
|
|
||||
= help: the trait `Sync` is not implemented for `(dyn Any + Send + 'static)`
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/issue-64130-4-async-move.rs:25:31
|
||||
|
|
||||
LL | match client.status() {
|
||||
| ------ has type `&Client` which is not `Send`
|
||||
LL | 200 => {
|
||||
LL | let _x = get().await;
|
||||
| ^^^^^^ await occurs here, with `client` maybe used later
|
||||
...
|
||||
LL | }
|
||||
| - `client` is later dropped here
|
||||
help: consider moving this into a `let` binding to create a shorter lived borrow
|
||||
--> $DIR/issue-64130-4-async-move.rs:23:15
|
||||
|
|
||||
LL | match client.status() {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1,4 +1,8 @@
|
|||
// edition:2018
|
||||
// revisions: no_drop_tracking drop_tracking
|
||||
// [drop_tracking] check-pass
|
||||
// [drop_tracking] compile-flags: -Zdrop-tracking=yes
|
||||
// [no_drop_tracking] compile-flags: -Zdrop-tracking=no
|
||||
use std::any::Any;
|
||||
use std::future::Future;
|
||||
|
||||
|
|
@ -10,16 +14,16 @@ impl Client {
|
|||
}
|
||||
}
|
||||
|
||||
async fn get() { }
|
||||
async fn get() {}
|
||||
|
||||
pub fn foo() -> impl Future + Send {
|
||||
//~^ ERROR future cannot be sent between threads safely
|
||||
//[no_drop_tracking]~^ ERROR future cannot be sent between threads safely
|
||||
let client = Client(Box::new(true));
|
||||
async move {
|
||||
match client.status() {
|
||||
200 => {
|
||||
let _x = get().await;
|
||||
},
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue