fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #69854 - pietroalbini:stable-next, r=Centrilb8cedc00407

1.42.0
5.6 KiB172 linesraw
1error[E0505]: cannot move out of `x` because it is borrowed
2  --> $DIR/closure-borrow-spans.rs:5:13
3   |
4LL |     let f = || x.len();
5   |             -- - borrow occurs due to use in closure
6   |             |
7   |             borrow of `x` occurs here
8LL |     let y = x;
9   |             ^ move out of `x` occurs here
10LL |     f.use_ref();
11   |     - borrow later used here
12
13error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
14  --> $DIR/closure-borrow-spans.rs:11:13
15   |
16LL |     let f = || x;
17   |             -- - first borrow occurs due to use of `x` in closure
18   |             |
19   |             immutable borrow occurs here
20LL |     let y = &mut x;
21   |             ^^^^^^ mutable borrow occurs here
22LL |     f.use_ref();
23   |     - immutable borrow later used here
24
25error[E0597]: `x` does not live long enough
26  --> $DIR/closure-borrow-spans.rs:19:16
27   |
28LL |         f = || x;
29   |             -- ^ borrowed value does not live long enough
30   |             |
31   |             value captured here
32LL |     }
33   |     - `x` dropped here while still borrowed
34LL |     f.use_ref();
35   |     - borrow later used here
36
37error[E0506]: cannot assign to `x` because it is borrowed
38  --> $DIR/closure-borrow-spans.rs:26:5
39   |
40LL |     let f = || x;
41   |             -- - borrow occurs due to use in closure
42   |             |
43   |             borrow of `x` occurs here
44LL |     x = 1;
45   |     ^^^^^ assignment to borrowed `x` occurs here
46LL |     f.use_ref();
47   |     - borrow later used here
48
49error[E0503]: cannot use `x` because it was mutably borrowed
50  --> $DIR/closure-borrow-spans.rs:32:13
51   |
52LL |     let f = || x = 0;
53   |             -- - borrow occurs due to use of `x` in closure
54   |             |
55   |             borrow of `x` occurs here
56LL |     let y = x;
57   |             ^ use of borrowed `x`
58LL |     f.use_ref();
59   |     - borrow later used here
60
61error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
62  --> $DIR/closure-borrow-spans.rs:38:13
63   |
64LL |     let f = || x = 0;
65   |             -- - first borrow occurs due to use of `x` in closure
66   |             |
67   |             mutable borrow occurs here
68LL |     let y = &x;
69   |             ^^ immutable borrow occurs here
70LL |     f.use_ref();
71   |     - mutable borrow later used here
72
73error[E0499]: cannot borrow `x` as mutable more than once at a time
74  --> $DIR/closure-borrow-spans.rs:44:13
75   |
76LL |     let f = || x = 0;
77   |             -- - first borrow occurs due to use of `x` in closure
78   |             |
79   |             first mutable borrow occurs here
80LL |     let y = &mut x;
81   |             ^^^^^^ second mutable borrow occurs here
82LL |     f.use_ref();
83   |     - first borrow later used here
84
85error[E0597]: `x` does not live long enough
86  --> $DIR/closure-borrow-spans.rs:52:16
87   |
88LL |         f = || x = 0;
89   |             -- ^ borrowed value does not live long enough
90   |             |
91   |             value captured here
92LL |     }
93   |     - `x` dropped here while still borrowed
94LL |     f.use_ref();
95   |     - borrow later used here
96
97error[E0506]: cannot assign to `x` because it is borrowed
98  --> $DIR/closure-borrow-spans.rs:59:5
99   |
100LL |     let f = || x = 0;
101   |             -- - borrow occurs due to use in closure
102   |             |
103   |             borrow of `x` occurs here
104LL |     x = 1;
105   |     ^^^^^ assignment to borrowed `x` occurs here
106LL |     f.use_ref();
107   |     - borrow later used here
108
109error[E0505]: cannot move out of `x` because it is borrowed
110  --> $DIR/closure-borrow-spans.rs:65:13
111   |
112LL |     let f = || *x = 0;
113   |             --  - borrow occurs due to use in closure
114   |             |
115   |             borrow of `x` occurs here
116LL |     let y = x;
117   |             ^ move out of `x` occurs here
118LL |     f.use_ref();
119   |     - borrow later used here
120
121error[E0501]: cannot borrow `x` as immutable because previous closure requires unique access
122  --> $DIR/closure-borrow-spans.rs:71:13
123   |
124LL |     let f = || *x = 0;
125   |             --  - first borrow occurs due to use of `x` in closure
126   |             |
127   |             closure construction occurs here
128LL |     let y = &x;
129   |             ^^ second borrow occurs here
130LL |     f.use_ref();
131   |     - first borrow later used here
132
133error[E0501]: cannot borrow `x` as mutable because previous closure requires unique access
134  --> $DIR/closure-borrow-spans.rs:77:13
135   |
136LL |     let f = || *x = 0;
137   |             --  - first borrow occurs due to use of `x` in closure
138   |             |
139   |             closure construction occurs here
140LL |     let y = &mut x;
141   |             ^^^^^^ second borrow occurs here
142LL |     f.use_ref();
143   |     - first borrow later used here
144
145error[E0597]: `x` does not live long enough
146  --> $DIR/closure-borrow-spans.rs:86:17
147   |
148LL |         f = || *x = 0;
149   |             --  ^ borrowed value does not live long enough
150   |             |
151   |             value captured here
152LL |     }
153   |     - `x` dropped here while still borrowed
154LL |     f.use_ref();
155   |     - borrow later used here
156
157error[E0506]: cannot assign to `*x` because it is borrowed
158  --> $DIR/closure-borrow-spans.rs:93:5
159   |
160LL |     let f = || *x = 0;
161   |             --  - borrow occurs due to use in closure
162   |             |
163   |             borrow of `*x` occurs here
164LL |     *x = 1;
165   |     ^^^^^^ assignment to borrowed `*x` occurs here
166LL |     f.use_ref();
167   |     - borrow later used here
168
169error: aborting due to 14 previous errors
170
171Some errors have detailed explanations: E0499, E0501, E0502, E0503, E0505, E0506, E0597.
172For more information about an error, try `rustc --explain E0499`.