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.4 KiB35 linesraw
1error: lifetime may not live long enough
2  --> $DIR/regions-addr-of-upvar-self.rs:10:20
3   |
4LL |         let _f = || {
5   |                  -- lifetime `'1` represents this closure's body
6LL |             let p: &'static mut usize = &mut self.food;
7   |                    ^^^^^^^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static`
8   |
9   = note: closure implements `FnMut`, so references to captured variables can't escape the closure
10
11error: lifetime may not live long enough
12  --> $DIR/regions-addr-of-upvar-self.rs:10:20
13   |
14LL |     pub fn chase_cat(&mut self) {
15   |                      - let's call the lifetime of this reference `'1`
16LL |         let _f = || {
17LL |             let p: &'static mut usize = &mut self.food;
18   |                    ^^^^^^^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static`
19
20error[E0597]: `self` does not live long enough
21  --> $DIR/regions-addr-of-upvar-self.rs:10:46
22   |
23LL |         let _f = || {
24   |                  -- value captured here
25LL |             let p: &'static mut usize = &mut self.food;
26   |                    ------------------        ^^^^ borrowed value does not live long enough
27   |                    |
28   |                    type annotation requires that `self` is borrowed for `'static`
29...
30LL |     }
31   |      - `self` dropped here while still borrowed
32
33error: aborting due to 3 previous errors
34
35For more information about this error, try `rustc --explain E0597`.