fork/rust

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

borsAuto merge of #71868 - Mark-Simulacrum:stable-1.43.1, r=pietroalbini8d69840ab92

1.43.1
1.1 KiB29 linesraw
1error[E0373]: closure may outlive the current function, but it borrows `self`, which is owned by the current function
2  --> $DIR/issue-62097.rs:13:13
3   |
4LL |         foo(|| self.bar()).await;
5   |             ^^ ---- `self` is borrowed here
6   |             |
7   |             may outlive borrowed value `self`
8   |
9note: function requires argument type to outlive `'static`
10  --> $DIR/issue-62097.rs:13:9
11   |
12LL |         foo(|| self.bar()).await;
13   |         ^^^^^^^^^^^^^^^^^^
14help: to force the closure to take ownership of `self` (and any other referenced variables), use the `move` keyword
15   |
16LL |         foo(move || self.bar()).await;
17   |             ^^^^^^^
18
19error[E0521]: borrowed data escapes outside of method
20  --> $DIR/issue-62097.rs:13:9
21   |
22LL |     pub async fn run_dummy_fn(&self) {
23   |                               ----- `self` is a reference that is only valid in the method body
24LL |         foo(|| self.bar()).await;
25   |         ^^^^^^^^^^^^^^^^^^ `self` escapes the method body here
26
27error: aborting due to 2 previous errors
28
29For more information about this error, try `rustc --explain E0373`.