Skip to content

Commit 10aaba8

Browse files
committed
Make move errors more consistent with typeck errors
1 parent 701c74e commit 10aaba8

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

src/librustc_mir/borrow_check/move_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
360360
} else {
361361
err.span_suggestion(
362362
span,
363-
"consider using a reference instead",
363+
"consider borrowing here",
364364
format!("&{}", snippet),
365365
);
366366
}

src/test/ui/suggestions/dont-suggest-ref.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,26 +110,26 @@ pub fn main() {
110110

111111
let X(_t) = vs_[0];
112112
//~^ ERROR cannot move
113-
//~| HELP consider using a reference instead
113+
//~| HELP consider borrowing here
114114
//~| SUGGESTION &vs_[0]
115115
if let Either::One(_t) = vr[0] { }
116116
//~^ ERROR cannot move
117-
//~| HELP consider using a reference instead
117+
//~| HELP consider borrowing here
118118
//~| SUGGESTION &vr[0]
119119
while let Either::One(_t) = vr[0] { }
120120
//~^ ERROR cannot move
121-
//~| HELP consider using a reference instead
121+
//~| HELP consider borrowing here
122122
//~| SUGGESTION &vr[0]
123123
match vr[0] {
124124
//~^ ERROR cannot move
125-
//~| HELP consider using a reference instead
125+
//~| HELP consider borrowing here
126126
//~| SUGGESTION &vr[0]
127127
Either::One(_t)
128128
| Either::Two(_t) => (),
129129
}
130130
match vr[0] {
131131
//~^ ERROR cannot move
132-
//~| HELP consider using a reference instead
132+
//~| HELP consider borrowing here
133133
//~| SUGGESTION &vr[0]
134134
Either::One(_t) => (),
135135
Either::Two(ref _t) => (),
@@ -138,34 +138,34 @@ pub fn main() {
138138

139139
let X(_t) = vsm[0];
140140
//~^ ERROR cannot move
141-
//~| HELP consider using a reference instead
141+
//~| HELP consider borrowing here
142142
//~| SUGGESTION &vsm[0]
143143
if let Either::One(_t) = vrm[0] { }
144144
//~^ ERROR cannot move
145-
//~| HELP consider using a reference instead
145+
//~| HELP consider borrowing here
146146
//~| SUGGESTION &vrm[0]
147147
while let Either::One(_t) = vrm[0] { }
148148
//~^ ERROR cannot move
149-
//~| HELP consider using a reference instead
149+
//~| HELP consider borrowing here
150150
//~| SUGGESTION &vrm[0]
151151
match vrm[0] {
152152
//~^ ERROR cannot move
153-
//~| HELP consider using a reference instead
153+
//~| HELP consider borrowing here
154154
//~| SUGGESTION &vrm[0]
155155
Either::One(_t)
156156
| Either::Two(_t) => (),
157157
}
158158
match vrm[0] {
159159
//~^ ERROR cannot move
160-
//~| HELP consider using a reference instead
160+
//~| HELP consider borrowing here
161161
//~| SUGGESTION &vrm[0]
162162
Either::One(_t) => (),
163163
Either::Two(ref _t) => (),
164164
// TODO: should suggest removing `ref` too
165165
}
166166
match vrm[0] {
167167
//~^ ERROR cannot move
168-
//~| HELP consider using a reference instead
168+
//~| HELP consider borrowing here
169169
//~| SUGGESTION &vrm[0]
170170
Either::One(_t) => (),
171171
Either::Two(ref mut _t) => (),

src/test/ui/suggestions/dont-suggest-ref.stderr

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ LL | let X(_t) = vs_[0];
191191
| -- ^^^^^^
192192
| | |
193193
| | cannot move out of borrowed content
194-
| | help: consider using a reference instead: `&vs_[0]`
194+
| | help: consider borrowing here: `&vs_[0]`
195195
| data moved here
196196
|
197197
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
@@ -207,7 +207,7 @@ LL | if let Either::One(_t) = vr[0] { }
207207
| -- ^^^^^
208208
| | |
209209
| | cannot move out of borrowed content
210-
| | help: consider using a reference instead: `&vr[0]`
210+
| | help: consider borrowing here: `&vr[0]`
211211
| data moved here
212212
|
213213
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
@@ -223,7 +223,7 @@ LL | while let Either::One(_t) = vr[0] { }
223223
| -- ^^^^^
224224
| | |
225225
| | cannot move out of borrowed content
226-
| | help: consider using a reference instead: `&vr[0]`
226+
| | help: consider borrowing here: `&vr[0]`
227227
| data moved here
228228
|
229229
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
@@ -239,7 +239,7 @@ LL | match vr[0] {
239239
| ^^^^^
240240
| |
241241
| cannot move out of borrowed content
242-
| help: consider using a reference instead: `&vr[0]`
242+
| help: consider borrowing here: `&vr[0]`
243243
...
244244
LL | Either::One(_t)
245245
| -- data moved here
@@ -257,7 +257,7 @@ LL | match vr[0] {
257257
| ^^^^^
258258
| |
259259
| cannot move out of borrowed content
260-
| help: consider using a reference instead: `&vr[0]`
260+
| help: consider borrowing here: `&vr[0]`
261261
...
262262
LL | Either::One(_t) => (),
263263
| -- data moved here
@@ -275,7 +275,7 @@ LL | let X(_t) = vsm[0];
275275
| -- ^^^^^^
276276
| | |
277277
| | cannot move out of borrowed content
278-
| | help: consider using a reference instead: `&vsm[0]`
278+
| | help: consider borrowing here: `&vsm[0]`
279279
| data moved here
280280
|
281281
note: move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
@@ -291,7 +291,7 @@ LL | if let Either::One(_t) = vrm[0] { }
291291
| -- ^^^^^^
292292
| | |
293293
| | cannot move out of borrowed content
294-
| | help: consider using a reference instead: `&vrm[0]`
294+
| | help: consider borrowing here: `&vrm[0]`
295295
| data moved here
296296
|
297297
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
@@ -307,7 +307,7 @@ LL | while let Either::One(_t) = vrm[0] { }
307307
| -- ^^^^^^
308308
| | |
309309
| | cannot move out of borrowed content
310-
| | help: consider using a reference instead: `&vrm[0]`
310+
| | help: consider borrowing here: `&vrm[0]`
311311
| data moved here
312312
|
313313
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
@@ -323,7 +323,7 @@ LL | match vrm[0] {
323323
| ^^^^^^
324324
| |
325325
| cannot move out of borrowed content
326-
| help: consider using a reference instead: `&vrm[0]`
326+
| help: consider borrowing here: `&vrm[0]`
327327
...
328328
LL | Either::One(_t)
329329
| -- data moved here
@@ -341,7 +341,7 @@ LL | match vrm[0] {
341341
| ^^^^^^
342342
| |
343343
| cannot move out of borrowed content
344-
| help: consider using a reference instead: `&vrm[0]`
344+
| help: consider borrowing here: `&vrm[0]`
345345
...
346346
LL | Either::One(_t) => (),
347347
| -- data moved here
@@ -359,7 +359,7 @@ LL | match vrm[0] {
359359
| ^^^^^^
360360
| |
361361
| cannot move out of borrowed content
362-
| help: consider using a reference instead: `&vrm[0]`
362+
| help: consider borrowing here: `&vrm[0]`
363363
...
364364
LL | Either::One(_t) => (),
365365
| -- data moved here

0 commit comments

Comments
 (0)