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