Files
rust/src/test/ui/async-await/issues/issue-62097.nll.stderr

30 lines
1.1 KiB
Plaintext
Raw Normal View History

2019-10-24 01:28:55 +08:00
error[E0373]: closure may outlive the current function, but it borrows `self`, which is owned by the current function
--> $DIR/issue-62097.rs:13:13
|
LL | foo(|| self.bar()).await;
| ^^ ---- `self` is borrowed here
| |
| may outlive borrowed value `self`
|
note: function requires argument type to outlive `'static`
--> $DIR/issue-62097.rs:13:9
|
LL | foo(|| self.bar()).await;
| ^^^^^^^^^^^^^^^^^^
help: to force the closure to take ownership of `self` (and any other referenced variables), use the `move` keyword
|
LL | foo(move || self.bar()).await;
| ^^^^^^^
2020-03-04 21:03:15 -06:00
error[E0521]: borrowed data escapes outside of associated function
2019-10-24 01:28:55 +08:00
--> $DIR/issue-62097.rs:13:9
|
LL | pub async fn run_dummy_fn(&self) {
2020-03-04 21:03:15 -06:00
| ----- `self` is a reference that is only valid in the associated function body
2019-10-24 01:28:55 +08:00
LL | foo(|| self.bar()).await;
2020-03-04 21:03:15 -06:00
| ^^^^^^^^^^^^^^^^^^ `self` escapes the associated function body here
2019-10-24 01:28:55 +08:00
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0373`.