fork/rust

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

borsAuto merge of #69854 - pietroalbini:stable-next, r=Centrilb8cedc00407

1.42.0
2.5 KiB70 linesraw
1error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
2  --> $DIR/regions-nested-fns.rs:5:18
3   |
4LL |     let mut ay = &y;
5   |                  ^^
6   |
7note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 7:58...
8  --> $DIR/regions-nested-fns.rs:7:58
9   |
10LL |       ignore::<Box<dyn for<'z> FnMut(&'z isize)>>(Box::new(|z| {
11   |  __________________________________________________________^
12LL | |         ay = x;
13LL | |         ay = &y;
14LL | |         ay = z;
15LL | |     }));
16   | |_____^
17note: ...so that reference does not outlive borrowed content
18  --> $DIR/regions-nested-fns.rs:10:14
19   |
20LL |         ay = z;
21   |              ^
22note: but, the lifetime must be valid for the anonymous lifetime #2 defined on the body at 13:72...
23  --> $DIR/regions-nested-fns.rs:13:72
24   |
25LL |       ignore::< Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
26   |  ________________________________________________________________________^
27LL | |         if false { return x; }
28LL | |         if false { return ay; }
29LL | |         return z;
30LL | |     }));
31   | |_____^
32note: ...so that the types are compatible
33  --> $DIR/regions-nested-fns.rs:13:76
34   |
35LL |       ignore::< Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
36   |  ____________________________________________________________________________^
37LL | |         if false { return x; }
38LL | |         if false { return ay; }
39LL | |         return z;
40LL | |     }));
41   | |_____^
42   = note: expected  `&isize`
43              found  `&isize`
44
45error[E0312]: lifetime of reference outlives lifetime of borrowed content...
46  --> $DIR/regions-nested-fns.rs:14:27
47   |
48LL |         if false { return x; }
49   |                           ^
50   |
51note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 13:72...
52  --> $DIR/regions-nested-fns.rs:13:72
53   |
54LL |       ignore::< Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
55   |  ________________________________________________________________________^
56LL | |         if false { return x; }
57LL | |         if false { return ay; }
58LL | |         return z;
59LL | |     }));
60   | |_____^
61note: ...but the borrowed content is only valid for the lifetime `'x` as defined on the function body at 3:11
62  --> $DIR/regions-nested-fns.rs:3:11
63   |
64LL | fn nested<'x>(x: &'x isize) {
65   |           ^^
66
67error: aborting due to 2 previous errors
68
69Some errors have detailed explanations: E0312, E0495.
70For more information about an error, try `rustc --explain E0312`.