1
1
error: unsatisfied lifetime constraints
2
- --> $DIR/closure-substs.rs:17 :16
2
+ --> $DIR/closure-substs.rs:18 :16
3
3
|
4
4
LL | fn foo<'a>() {
5
5
| -- 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
8
8
| ^ returning this value requires that `'a` must outlive `'static`
9
9
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
+
10
50
error: borrowed data escapes outside of closure
11
- --> $DIR/closure-substs.rs:23 :9
51
+ --> $DIR/closure-substs.rs:41 :9
12
52
|
13
53
LL | |x: &i32, b: fn(&'static i32)| {
14
54
| - `x` is a reference that is only valid in the closure body
15
55
LL | b(x); //~ ERROR
16
56
| ^^^^ `x` escapes the closure body here
17
57
18
58
error: borrowed data escapes outside of closure
19
- --> $DIR/closure-substs.rs:23 :9
59
+ --> $DIR/closure-substs.rs:41 :9
20
60
|
21
61
LL | |x: &i32, b: fn(&'static i32)| {
22
62
| - - `b` is declared here, outside of the closure body
@@ -26,7 +66,7 @@ LL | b(x); //~ ERROR
26
66
| ^^^^ `x` escapes the closure body here
27
67
28
68
error: unsatisfied lifetime constraints
29
- --> $DIR/closure-substs.rs:23 :9
69
+ --> $DIR/closure-substs.rs:41 :9
30
70
|
31
71
LL | |x: &i32, b: fn(&'static i32)| {
32
72
| ------------------------------
@@ -38,5 +78,5 @@ LL | b(x); //~ ERROR
38
78
|
39
79
= note: closure implements `Fn`, so references to captured variables can't escape the closure
40
80
41
- error: aborting due to 4 previous errors
81
+ error: aborting due to 8 previous errors
42
82
0 commit comments