]>
Commit | Line | Data |
---|---|---|
48663c56 XL |
1 | error[E0521]: borrowed data escapes outside of closure |
2 | --> $DIR/regions-nested-fns.rs:10:9 | |
3 | | | |
4 | LL | let mut ay = &y; | |
74b04a01 | 5 | | ------ `ay` declared here, outside of the closure body |
48663c56 | 6 | LL | |
dc9dc135 XL |
7 | LL | ignore::<Box<dyn for<'z> FnMut(&'z isize)>>(Box::new(|z| { |
8 | | - `z` is a reference that is only valid in the closure body | |
48663c56 XL |
9 | ... |
10 | LL | ay = z; | |
11 | | ^^^^^^ `z` escapes the closure body here | |
12 | ||
13 | error[E0597]: `y` does not live long enough | |
14 | --> $DIR/regions-nested-fns.rs:5:18 | |
15 | | | |
16 | LL | let mut ay = &y; | |
17 | | ^^ borrowed value does not live long enough | |
18 | ... | |
19 | LL | if false { return ay; } | |
20 | | -- returning this value requires that `y` is borrowed for `'static` | |
21 | ... | |
22 | LL | } | |
23 | | - `y` dropped here while still borrowed | |
24 | ||
25 | error[E0597]: `y` does not live long enough | |
26 | --> $DIR/regions-nested-fns.rs:9:15 | |
27 | | | |
dc9dc135 XL |
28 | LL | ignore::<Box<dyn for<'z> FnMut(&'z isize)>>(Box::new(|z| { |
29 | | --- value captured here | |
48663c56 XL |
30 | LL | ay = x; |
31 | LL | ay = &y; | |
32 | | ^ borrowed value does not live long enough | |
33 | ... | |
34 | LL | if false { return ay; } | |
35 | | -- returning this value requires that `y` is borrowed for `'static` | |
36 | ... | |
37 | LL | } | |
38 | | - `y` dropped here while still borrowed | |
39 | ||
40 | error: lifetime may not live long enough | |
41 | --> $DIR/regions-nested-fns.rs:14:27 | |
42 | | | |
43 | LL | fn nested<'x>(x: &'x isize) { | |
44 | | -- lifetime `'x` defined here | |
45 | ... | |
46 | LL | if false { return x; } | |
47 | | ^ returning this value requires that `'x` must outlive `'static` | |
60c5eb7d XL |
48 | | |
49 | = help: consider replacing `'x` with `'static` | |
48663c56 XL |
50 | |
51 | error: aborting due to 4 previous errors | |
52 | ||
5869c6ff XL |
53 | Some errors have detailed explanations: E0521, E0597. |
54 | For more information about an error, try `rustc --explain E0521`. |