fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #72883 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum49cae55760d

1.44.0
1.5 KiB41 linesraw
1error[E0373]: async block may outlive the current function, but it borrows `x`, which is owned by the current function
2  --> $DIR/async-borrowck-escaping-block-error.rs:6:20
3   |
4LL |     Box::new(async { x } )
5   |                    ^^-^^
6   |                    | |
7   |                    | `x` is borrowed here
8   |                    may outlive borrowed value `x`
9   |
10note: async block is returned here
11  --> $DIR/async-borrowck-escaping-block-error.rs:4:20
12   |
13LL | fn test_boxed() -> Box<impl std::future::Future<Output = u32>> {
14   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15help: to force the async block to take ownership of `x` (and any other referenced variables), use the `move` keyword
16   |
17LL |     Box::new(async move { x } )
18   |                    ^^^^^^^^^^
19
20error[E0373]: async block may outlive the current function, but it borrows `x`, which is owned by the current function
21  --> $DIR/async-borrowck-escaping-block-error.rs:11:11
22   |
23LL |     async { *x }
24   |           ^^^-^^
25   |           |  |
26   |           |  `x` is borrowed here
27   |           may outlive borrowed value `x`
28   |
29note: async block is returned here
30  --> $DIR/async-borrowck-escaping-block-error.rs:11:5
31   |
32LL |     async { *x }
33   |     ^^^^^^^^^^^^
34help: to force the async block to take ownership of `x` (and any other referenced variables), use the `move` keyword
35   |
36LL |     async move { *x }
37   |           ^^^^^^^^^^^
38
39error: aborting due to 2 previous errors
40
41For more information about this error, try `rustc --explain E0373`.