blob: cac22c2ecda4974d48e1795f4eb5ca7f3ed345fe (
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
error[E0505]: cannot move out of `x` because it is borrowed
--> $DIR/closure-borrow-spans.rs:5:13
|
LL | let f = || x.len();
| -- - borrow occurs due to use in closure
| |
| borrow of `x` occurs here
LL | let y = x;
| ^ move out of `x` occurs here
LL | f.use_ref();
| - borrow later used here
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/closure-borrow-spans.rs:11:13
|
LL | let f = || x;
| -- - first borrow occurs due to use of `x` in closure
| |
| immutable borrow occurs here
LL | let y = &mut x;
| ^^^^^^ mutable borrow occurs here
LL | f.use_ref();
| - immutable borrow later used here
error[E0597]: `x` does not live long enough
--> $DIR/closure-borrow-spans.rs:19:16
|
LL | f = || x;
| -- ^ borrowed value does not live long enough
| |
| value captured here
LL | }
| - `x` dropped here while still borrowed
LL | f.use_ref();
| - borrow later used here
error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/closure-borrow-spans.rs:26:5
|
LL | let f = || x;
| -- - borrow occurs due to use in closure
| |
| `x` is borrowed here
LL | x = 1;
| ^^^^^ `x` is assigned to here but it was already borrowed
LL | f.use_ref();
| - borrow later used here
error[E0503]: cannot use `x` because it was mutably borrowed
--> $DIR/closure-borrow-spans.rs:32:13
|
LL | let f = || x = 0;
| -- - borrow occurs due to use of `x` in closure
| |
| `x` is borrowed here
LL | let y = x;
| ^ use of borrowed `x`
LL | f.use_ref();
| - borrow later used here
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
--> $DIR/closure-borrow-spans.rs:38:13
|
LL | let f = || x = 0;
| -- - first borrow occurs due to use of `x` in closure
| |
| mutable borrow occurs here
LL | let y = &x;
| ^^ immutable borrow occurs here
LL | f.use_ref();
| - mutable borrow later used here
error[E0499]: cannot borrow `x` as mutable more than once at a time
--> $DIR/closure-borrow-spans.rs:44:13
|
LL | let f = || x = 0;
| -- - first borrow occurs due to use of `x` in closure
| |
| first mutable borrow occurs here
LL | let y = &mut x;
| ^^^^^^ second mutable borrow occurs here
LL | f.use_ref();
| - first borrow later used here
error[E0597]: `x` does not live long enough
--> $DIR/closure-borrow-spans.rs:52:16
|
LL | f = || x = 0;
| -- ^ borrowed value does not live long enough
| |
| value captured here
LL | }
| - `x` dropped here while still borrowed
LL | f.use_ref();
| - borrow later used here
error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/closure-borrow-spans.rs:59:5
|
LL | let f = || x = 0;
| -- - borrow occurs due to use in closure
| |
| `x` is borrowed here
LL | x = 1;
| ^^^^^ `x` is assigned to here but it was already borrowed
LL | f.use_ref();
| - borrow later used here
error[E0505]: cannot move out of `x` because it is borrowed
--> $DIR/closure-borrow-spans.rs:65:13
|
LL | let f = || *x = 0;
| -- -- borrow occurs due to use in closure
| |
| borrow of `x` occurs here
LL | let y = x;
| ^ move out of `x` occurs here
LL | f.use_ref();
| - borrow later used here
error[E0501]: cannot borrow `x` as immutable because previous closure requires unique access
--> $DIR/closure-borrow-spans.rs:71:13
|
LL | let f = || *x = 0;
| -- -- first borrow occurs due to use of `x` in closure
| |
| closure construction occurs here
LL | let y = &x;
| ^^ second borrow occurs here
LL | f.use_ref();
| - first borrow later used here
error[E0501]: cannot borrow `x` as mutable because previous closure requires unique access
--> $DIR/closure-borrow-spans.rs:77:13
|
LL | let f = || *x = 0;
| -- -- first borrow occurs due to use of `x` in closure
| |
| closure construction occurs here
LL | let y = &mut x;
| ^^^^^^ second borrow occurs here
LL | f.use_ref();
| - first borrow later used here
error[E0597]: `x` does not live long enough
--> $DIR/closure-borrow-spans.rs:86:16
|
LL | f = || *x = 0;
| -- ^^ borrowed value does not live long enough
| |
| value captured here
LL | }
| - `x` dropped here while still borrowed
LL | f.use_ref();
| - borrow later used here
error[E0506]: cannot assign to `*x` because it is borrowed
--> $DIR/closure-borrow-spans.rs:93:5
|
LL | let f = || *x = 0;
| -- -- borrow occurs due to use in closure
| |
| `*x` is borrowed here
LL | *x = 1;
| ^^^^^^ `*x` is assigned to here but it was already borrowed
LL | f.use_ref();
| - borrow later used here
error: aborting due to 14 previous errors
Some errors have detailed explanations: E0499, E0501, E0502, E0503, E0505, E0506, E0597.
For more information about an error, try `rustc --explain E0499`.
|