2022-10-27 16:22:06 +00:00
|
|
|
error[E0507]: cannot move out of `self.b`, as `self` is a captured variable in an `Fn` closure
|
|
|
|
--> $DIR/issue-103624.rs:16:13
|
|
|
|
|
|
|
|
|
LL | async fn foo(&self) {
|
|
|
|
| ----- captured outer variable
|
|
|
|
LL | let bar = self.b.bar().await;
|
|
|
|
LL | spawn_blocking(move || {
|
|
|
|
| ------- captured by this `Fn` closure
|
|
|
|
LL |
|
|
|
|
LL | self.b;
|
|
|
|
| ^^^^^^ move occurs because `self.b` has type `StructB`, which does not implement the `Copy` trait
|
|
|
|
|
2023-02-21 21:11:08 +00:00
|
|
|
error[E0521]: borrowed data escapes outside of method
|
2022-10-27 16:22:06 +00:00
|
|
|
--> $DIR/issue-103624.rs:14:9
|
|
|
|
|
|
|
|
|
LL | async fn foo(&self) {
|
|
|
|
| -----
|
|
|
|
| |
|
2023-02-21 21:11:08 +00:00
|
|
|
| `self` is a reference that is only valid in the method body
|
2022-10-27 16:22:06 +00:00
|
|
|
| let's call the lifetime of this reference `'1`
|
|
|
|
LL | let bar = self.b.bar().await;
|
|
|
|
LL | / spawn_blocking(move || {
|
|
|
|
LL | |
|
|
|
|
LL | | self.b;
|
|
|
|
LL | |
|
|
|
|
LL | | })
|
|
|
|
| | ^
|
|
|
|
| | |
|
2023-02-21 21:11:08 +00:00
|
|
|
| |__________`self` escapes the method body here
|
2022-10-27 16:22:06 +00:00
|
|
|
| argument requires that `'1` must outlive `'static`
|
|
|
|
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
|
|
|
|
Some errors have detailed explanations: E0507, E0521.
|
|
|
|
For more information about an error, try `rustc --explain E0507`.
|