2021-01-02 05:03:21 -06:00
|
|
|
error[E0373]: async block may outlive the current function, but it borrows `room_ref`, which is owned by the current function
|
2022-11-18 15:56:22 -06:00
|
|
|
--> $DIR/issue-78938-async-block.rs:8:33
|
2021-01-02 05:03:21 -06:00
|
|
|
|
|
|
|
|
LL | let gameloop_handle = spawn(async {
|
2022-11-18 15:56:22 -06:00
|
|
|
| _________________________________^
|
2021-01-02 05:03:21 -06:00
|
|
|
LL | | game_loop(Arc::clone(&room_ref))
|
|
|
|
| | -------- `room_ref` is borrowed here
|
|
|
|
LL | | });
|
|
|
|
| |_____^ may outlive borrowed value `room_ref`
|
|
|
|
|
|
2021-01-11 21:12:12 -06:00
|
|
|
= note: async blocks are not executed immediately and must either take a reference or ownership of outside variables they use
|
2021-01-02 05:03:21 -06:00
|
|
|
help: to force the async block to take ownership of `room_ref` (and any other referenced variables), use the `move` keyword
|
|
|
|
|
|
|
|
|
LL | let gameloop_handle = spawn(async move {
|
2021-06-21 21:07:19 -05:00
|
|
|
| ++++
|
2021-01-02 05:03:21 -06:00
|
|
|
|
2023-11-21 09:44:16 -06:00
|
|
|
error: aborting due to 1 previous error
|
2021-01-02 05:03:21 -06:00
|
|
|
|
|
|
|
For more information about this error, try `rustc --explain E0373`.
|