2020-04-07 21:57:26 +00:00
|
|
|
error[E0373]: async block may outlive the current function, but it borrows `x`, which is owned by the current function
|
2019-10-06 13:58:32 +00:00
|
|
|
--> $DIR/async-borrowck-escaping-block-error.rs:6:20
|
2019-10-06 13:57:23 +00:00
|
|
|
|
|
|
|
|
LL | Box::new(async { x } )
|
|
|
|
| ^^-^^
|
|
|
|
| | |
|
|
|
|
| | `x` is borrowed here
|
|
|
|
| may outlive borrowed value `x`
|
|
|
|
|
|
2020-04-07 21:57:26 +00:00
|
|
|
note: async block is returned here
|
|
|
|
--> $DIR/async-borrowck-escaping-block-error.rs:4:20
|
2019-10-06 13:57:23 +00:00
|
|
|
|
|
2020-04-07 21:57:26 +00:00
|
|
|
LL | fn test_boxed() -> Box<impl std::future::Future<Output = u32>> {
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2019-10-10 14:20:57 +00:00
|
|
|
help: to force the async block to take ownership of `x` (and any other referenced variables), use the `move` keyword
|
2019-10-06 13:57:23 +00:00
|
|
|
|
|
|
|
|
LL | Box::new(async move { x } )
|
2021-06-28 18:22:47 +00:00
|
|
|
| ^^^^
|
2019-10-06 13:57:23 +00:00
|
|
|
|
2020-04-07 21:57:26 +00:00
|
|
|
error[E0373]: async block may outlive the current function, but it borrows `x`, which is owned by the current function
|
|
|
|
--> $DIR/async-borrowck-escaping-block-error.rs:11:11
|
|
|
|
|
|
|
|
|
LL | async { *x }
|
2021-03-17 06:51:27 +00:00
|
|
|
| ^^--^^
|
|
|
|
| | |
|
|
|
|
| | `x` is borrowed here
|
2020-04-07 21:57:26 +00:00
|
|
|
| may outlive borrowed value `x`
|
|
|
|
|
|
|
|
|
note: async block is returned here
|
|
|
|
--> $DIR/async-borrowck-escaping-block-error.rs:11:5
|
|
|
|
|
|
|
|
|
LL | async { *x }
|
|
|
|
| ^^^^^^^^^^^^
|
|
|
|
help: to force the async block to take ownership of `x` (and any other referenced variables), use the `move` keyword
|
|
|
|
|
|
|
|
|
LL | async move { *x }
|
2021-06-28 18:22:47 +00:00
|
|
|
| ^^^^
|
2020-04-07 21:57:26 +00:00
|
|
|
|
|
|
|
error: aborting due to 2 previous errors
|
2019-10-06 13:57:23 +00:00
|
|
|
|
|
|
|
For more information about this error, try `rustc --explain E0373`.
|