]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-nested-fns.stderr
update comment to explain the importance of this check more clearly
[rust.git] / src / test / ui / regions / regions-nested-fns.stderr
1 error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
2   --> $DIR/regions-nested-fns.rs:5:18
3    |
4 LL |     let mut ay = &y;
5    |                  ^^
6    |
7 note: 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    |
10 LL |       ignore::<Box<dyn for<'z> FnMut(&'z isize)>>(Box::new(|z| {
11    |  __________________________________________________________^
12 LL | |         ay = x;
13 LL | |         ay = &y;
14 LL | |         ay = z;
15 LL | |     }));
16    | |_____^
17 note: ...so that reference does not outlive borrowed content
18   --> $DIR/regions-nested-fns.rs:10:14
19    |
20 LL |         ay = z;
21    |              ^
22 note: 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    |
25 LL |       ignore::< Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
26    |  ________________________________________________________________________^
27 LL | |         if false { return x; }
28 LL | |         if false { return ay; }
29 LL | |         return z;
30 LL | |     }));
31    | |_____^
32    = note: ...so that the types are compatible:
33            expected &isize
34               found &isize
35
36 error[E0312]: lifetime of reference outlives lifetime of borrowed content...
37   --> $DIR/regions-nested-fns.rs:14:27
38    |
39 LL |         if false { return x; }
40    |                           ^
41    |
42 note: ...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    |
45 LL |       ignore::< Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
46    |  ________________________________________________________________________^
47 LL | |         if false { return x; }
48 LL | |         if false { return ay; }
49 LL | |         return z;
50 LL | |     }));
51    | |_____^
52 note: ...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    |
55 LL | fn nested<'x>(x: &'x isize) {
56    |           ^^
57
58 error: aborting due to 2 previous errors
59
60 Some errors have detailed explanations: E0312, E0495.
61 For more information about an error, try `rustc --explain E0312`.