blob: bdf2820887c8bda449ad75e2425facdae5d449cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
error[E0506]: cannot assign to `*x` because it is borrowed
--> $DIR/issue-74072-lifetime-name-annotations.rs:9:5
|
LL | pub async fn async_fn(x: &mut i32) -> &i32 {
| - let's call the lifetime of this reference `'1`
LL | let y = &*x;
| --- `*x` is borrowed here
LL | *x += 1;
| ^^^^^^^ `*x` is assigned to here but it was already borrowed
LL | y
| - returning this value requires that `*x` is borrowed for `'1`
error[E0506]: cannot assign to `*x` because it is borrowed
--> $DIR/issue-74072-lifetime-name-annotations.rs:18:9
|
LL | let y = &*x;
| --- `*x` is borrowed here
LL | *x += 1;
| ^^^^^^^ `*x` is assigned to here but it was already borrowed
LL | y
| - returning this value requires that `*x` is borrowed for `'1`
LL | })()
| - return type of async closure is &'1 i32
error: lifetime may not live long enough
--> $DIR/issue-74072-lifetime-name-annotations.rs:14:20
|
LL | (async move || {
| ______-------------_^
| | | |
| | | return type of async closure `{async closure body@$DIR/issue-74072-lifetime-name-annotations.rs:14:20: 20:6}` contains a lifetime `'2`
| | lifetime `'1` represents this closure's body
LL | |
LL | |
LL | | let y = &*x;
LL | | *x += 1;
LL | | y
LL | | })()
| |_____^ returning this value requires that `'1` must outlive `'2`
|
= note: closure implements `FnMut`, so references to captured variables can't escape the closure
error[E0716]: temporary value dropped while borrowed
--> $DIR/issue-74072-lifetime-name-annotations.rs:14:5
|
LL | pub fn async_closure(x: &mut i32) -> impl Future<Output=&i32> {
| - let's call the lifetime of this reference `'1`
LL | // (async move || {
LL | ||
LL | ||
LL | || let y = &*x;
LL | || *x += 1;
LL | || y
LL | || })()
| ||______^_- argument requires that borrow lasts for `'1`
| |_______|
| creates a temporary value which is freed while still in use
LL | }
| - temporary value is freed at the end of this statement
error[E0506]: cannot assign to `*x` because it is borrowed
--> $DIR/issue-74072-lifetime-name-annotations.rs:28:9
|
LL | let y = &*x;
| --- `*x` is borrowed here
LL | *x += 1;
| ^^^^^^^ `*x` is assigned to here but it was already borrowed
LL | y
| - returning this value requires that `*x` is borrowed for `'1`
LL | })()
| - return type of async closure is &'1 i32
error: lifetime may not live long enough
--> $DIR/issue-74072-lifetime-name-annotations.rs:24:28
|
LL | (async move || -> &i32 {
| ______---------------------_^
| | | |
| | | return type of async closure `{async closure body@$DIR/issue-74072-lifetime-name-annotations.rs:24:28: 30:6}` contains a lifetime `'2`
| | lifetime `'1` represents this closure's body
LL | |
LL | |
LL | | let y = &*x;
LL | | *x += 1;
LL | | y
LL | | })()
| |_____^ returning this value requires that `'1` must outlive `'2`
|
= note: closure implements `FnMut`, so references to captured variables can't escape the closure
error[E0716]: temporary value dropped while borrowed
--> $DIR/issue-74072-lifetime-name-annotations.rs:24:5
|
LL | pub fn async_closure_explicit_return_type(x: &mut i32) -> impl Future<Output=&i32> {
| - let's call the lifetime of this reference `'1`
LL | // (async move || -> &i32 {
LL | ||
LL | ||
LL | || let y = &*x;
LL | || *x += 1;
LL | || y
LL | || })()
| ||______^_- argument requires that borrow lasts for `'1`
| |_______|
| creates a temporary value which is freed while still in use
LL | }
| - temporary value is freed at the end of this statement
error[E0506]: cannot assign to `*x` because it is borrowed
--> $DIR/issue-74072-lifetime-name-annotations.rs:36:9
|
LL | let y = &*x;
| --- `*x` is borrowed here
LL | *x += 1;
| ^^^^^^^ `*x` is assigned to here but it was already borrowed
LL | y
| - returning this value requires that `*x` is borrowed for `'1`
LL | }
| - return type of async block is &'1 i32
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0506, E0716.
For more information about an error, try `rustc --explain E0506`.
|