]> git.lizzy.rs Git - rust.git/blob - tests/ui/regions/regions-addr-of-upvar-self.stderr
add UI test + docs for `E0789`
[rust.git] / tests / ui / regions / regions-addr-of-upvar-self.stderr
1 error: lifetime may not live long enough
2   --> $DIR/regions-addr-of-upvar-self.rs:8:20
3    |
4 LL |         let _f = || {
5    |                  -- lifetime `'1` represents this closure's body
6 LL |             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
11 error: lifetime may not live long enough
12   --> $DIR/regions-addr-of-upvar-self.rs:8:20
13    |
14 LL |     pub fn chase_cat(&mut self) {
15    |                      - let's call the lifetime of this reference `'1`
16 LL |         let _f = || {
17 LL |             let p: &'static mut usize = &mut self.food;
18    |                    ^^^^^^^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static`
19
20 error[E0597]: `self` does not live long enough
21   --> $DIR/regions-addr-of-upvar-self.rs:8:46
22    |
23 LL |         let _f = || {
24    |                  -- value captured here
25 LL |             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 ...
30 LL |     }
31    |      - `self` dropped here while still borrowed
32
33 error: aborting due to 3 previous errors
34
35 For more information about this error, try `rustc --explain E0597`.