11error: unsatisfied lifetime constraints
2- --> $DIR/closure-substs.rs:17 :16
2+ --> $DIR/closure-substs.rs:18 :16
33 |
44LL | fn foo<'a>() {
55 | -- lifetime `'a` defined here
6- LL | |x: &'a i32| -> &'static i32 {
7- LL | return x; //~ ERROR
6+ ...
7+ LL | return x; //~ ERROR unsatisfied lifetime constraints
88 | ^ returning this value requires that `'a` must outlive `'static`
99
10+ error: unsatisfied lifetime constraints
11+ --> $DIR/closure-substs.rs:25:16
12+ |
13+ LL | |x: &i32| -> &'static i32 {
14+ | - let's call the lifetime of this reference `'1`
15+ LL | return x; //~ ERROR unsatisfied lifetime constraints
16+ | ^ returning this value requires that `'1` must outlive `'static`
17+
18+ error: unsatisfied lifetime constraints
19+ --> $DIR/closure-substs.rs:25:16
20+ |
21+ LL | |x: &i32| -> &'static i32 {
22+ | - - return type of closure is &'2 i32
23+ | |
24+ | let's call the lifetime of this reference `'1`
25+ LL | return x; //~ ERROR unsatisfied lifetime constraints
26+ | ^ returning this value requires that `'1` must outlive `'2`
27+
28+ error: unsatisfied lifetime constraints
29+ --> $DIR/closure-substs.rs:25:16
30+ |
31+ LL | |x: &i32| -> &'static i32 {
32+ | -------------------------
33+ | | |
34+ | | let's call the lifetime of this reference `'1`
35+ | lifetime `'2` represents this closure's body
36+ LL | return x; //~ ERROR unsatisfied lifetime constraints
37+ | ^ closure was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
38+ |
39+ = note: closure implements `Fn`, so references to captured variables can't escape the closure
40+
41+ error: unsatisfied lifetime constraints
42+ --> $DIR/closure-substs.rs:34:9
43+ |
44+ LL | fn bar<'a>() {
45+ | -- lifetime `'a` defined here
46+ ...
47+ LL | b(x); //~ ERROR unsatisfied lifetime constraints
48+ | ^^^^ argument requires that `'a` must outlive `'static`
49+
1050error: borrowed data escapes outside of closure
11- --> $DIR/closure-substs.rs:23 :9
51+ --> $DIR/closure-substs.rs:41 :9
1252 |
1353LL | |x: &i32, b: fn(&'static i32)| {
1454 | - `x` is a reference that is only valid in the closure body
1555LL | b(x); //~ ERROR
1656 | ^^^^ `x` escapes the closure body here
1757
1858error: borrowed data escapes outside of closure
19- --> $DIR/closure-substs.rs:23 :9
59+ --> $DIR/closure-substs.rs:41 :9
2060 |
2161LL | |x: &i32, b: fn(&'static i32)| {
2262 | - - `b` is declared here, outside of the closure body
@@ -26,7 +66,7 @@ LL | b(x); //~ ERROR
2666 | ^^^^ `x` escapes the closure body here
2767
2868error: unsatisfied lifetime constraints
29- --> $DIR/closure-substs.rs:23 :9
69+ --> $DIR/closure-substs.rs:41 :9
3070 |
3171LL | |x: &i32, b: fn(&'static i32)| {
3272 | ------------------------------
@@ -38,5 +78,5 @@ LL | b(x); //~ ERROR
3878 |
3979 = note: closure implements `Fn`, so references to captured variables can't escape the closure
4080
41- error: aborting due to 4 previous errors
81+ error: aborting due to 8 previous errors
4282
0 commit comments