Skip to content

Commit 09006d8

Browse files
committed
review comments
1 parent 802d8c5 commit 09006d8

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

src/librustc_mir/borrow_check/error_reporting.rs

+10-15
Original file line numberDiff line numberDiff line change
@@ -203,20 +203,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
203203
Some(ref name) => format!("`{}`", name),
204204
None => "value".to_owned(),
205205
};
206-
let mut note = true;
207-
for decl in &self.mir.local_decls {
208-
if decl.ty == ty && decl.name.map(|x| x.to_string()) == opt_name {
209-
err.span_label(
210-
decl.source_info.span,
211-
format!(
212-
"move occurs because {} has type `{}`, \
213-
which does not implement the `Copy` trait",
214-
note_msg, ty,
215-
));
216-
note = false;
217-
break;
218-
}
219-
}
220206
if let ty::TyKind::Param(param_ty) = ty.sty {
221207
let tcx = self.infcx.tcx;
222208
let generics = tcx.generics_of(self.mir_def_id);
@@ -228,7 +214,16 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
228214
);
229215
}
230216
}
231-
if note {
217+
if let Place::Local(local) = place {
218+
let decl = &self.mir.local_decls[*local];
219+
err.span_label(
220+
decl.source_info.span,
221+
format!(
222+
"move occurs because {} has type `{}`, \
223+
which does not implement the `Copy` trait",
224+
note_msg, ty,
225+
));
226+
} else {
232227
err.note(&format!(
233228
"move occurs because {} has type `{}`, \
234229
which does not implement the `Copy` trait",

src/test/ui/borrowck/issue-41962.stderr

+1-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@ LL | if let Some(thing) = maybe {
1919
error[E0382]: use of moved value (Mir)
2020
--> $DIR/issue-41962.rs:7:21
2121
|
22-
LL | let maybe = Some(vec![true, true]);
23-
| ---------------- move occurs because value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
24-
...
2522
LL | if let Some(thing) = maybe {
2623
| ^^^^^ value moved here, in previous iteration of loop
2724
|
28-
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
25+
= note: move occurs because value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
2926

3027
error: aborting due to 3 previous errors
3128

0 commit comments

Comments
 (0)