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);
);
}
}
- 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",
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