fork/rust

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

borsAuto merge of #67350 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum73528e339aa

1.40.0
2.2 KiB61 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   | |_____^
32   = note: ...so that the types are compatible:
33           expected &isize
34              found &isize
35
36error[E0312]: lifetime of reference outlives lifetime of borrowed content...
37  --> $DIR/regions-nested-fns.rs:14:27
38   |
39LL |         if false { return x; }
40   |                           ^
41   |
42note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 13:72...
43  --> $DIR/regions-nested-fns.rs:13:72
44   |
45LL |       ignore::< Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
46   |  ________________________________________________________________________^
47LL | |         if false { return x; }
48LL | |         if false { return ay; }
49LL | |         return z;
50LL | |     }));
51   | |_____^
52note: ...but the borrowed content is only valid for the lifetime `'x` as defined on the function body at 3:11
53  --> $DIR/regions-nested-fns.rs:3:11
54   |
55LL | fn nested<'x>(x: &'x isize) {
56   |           ^^
57
58error: aborting due to 2 previous errors
59
60Some errors have detailed explanations: E0312, E0495.
61For more information about an error, try `rustc --explain E0312`.