fork/rust

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

borsAuto merge of #69444 - pietroalbini:stable-next-final-v2-new, r=pietroalbinif3e1a954d2e

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