Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
review comments
  • Loading branch information
estebank committed Jan 18, 2019
1 parent 802d8c5 commit 09006d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
25 changes: 10 additions & 15 deletions src/librustc_mir/borrow_check/error_reporting.rs
Expand Up @@ -203,20 +203,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
Some(ref name) => format!("`{}`", name),
None => "value".to_owned(),
};
let mut note = true;
for decl in &self.mir.local_decls {
if decl.ty == ty && decl.name.map(|x| x.to_string()) == opt_name {
err.span_label(
decl.source_info.span,
format!(
"move occurs because {} has type `{}`, \
which does not implement the `Copy` trait",
note_msg, ty,
));
note = false;
break;
}
}
if let ty::TyKind::Param(param_ty) = ty.sty {
let tcx = self.infcx.tcx;
let generics = tcx.generics_of(self.mir_def_id);
Expand All @@ -228,7 +214,16 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
);
}
}
if note {
if let Place::Local(local) = place {
let decl = &self.mir.local_decls[*local];
err.span_label(
decl.source_info.span,
format!(
"move occurs because {} has type `{}`, \
which does not implement the `Copy` trait",
note_msg, ty,
));
} else {
err.note(&format!(
"move occurs because {} has type `{}`, \
which does not implement the `Copy` trait",
Expand Down
5 changes: 1 addition & 4 deletions src/test/ui/borrowck/issue-41962.stderr
Expand Up @@ -19,13 +19,10 @@ LL | if let Some(thing) = maybe {
error[E0382]: use of moved value (Mir)
--> $DIR/issue-41962.rs:7:21
|
LL | let maybe = Some(vec![true, true]);
| ---------------- move occurs because value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
...
LL | if let Some(thing) = maybe {
| ^^^^^ value moved here, in previous iteration of loop
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
= note: move occurs because value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait

error: aborting due to 3 previous errors

Expand Down

0 comments on commit 09006d8

Please sign in to comment.