Tweak to mir borrow in a loop diagnostic

This commit is contained in:
Esteban Küber 2018-01-03 14:13:32 -08:00
parent e027f5a99e
commit a4d46b3d87
2 changed files with 12 additions and 11 deletions

View File

@ -62,13 +62,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
Origin::Mir,
);
err.span_label(
span,
format!(
"value {} here after move",
desired_action.as_verb_in_past_tense()
),
);
let mut is_loop_move = false;
for moi in mois {
let move_msg = ""; //FIXME: add " (into closure)"
let move_span = self.mir.source_info(self.move_data.moves[*moi].source).span;
@ -77,10 +71,20 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
span,
format!("value moved{} here in previous iteration of loop", move_msg),
);
is_loop_move = true;
} else {
err.span_label(move_span, format!("value moved{} here", move_msg));
};
}
if !is_loop_move {
err.span_label(
span,
format!(
"value {} here after move",
desired_action.as_verb_in_past_tense()
),
);
}
if let Some(ty) = self.retrieve_type_for_place(place) {
let needs_note = match ty.sty {

View File

@ -31,10 +31,7 @@ error[E0382]: use of moved value: `maybe.0` (Mir)
--> $DIR/issue-41962.rs:17:21
|
17 | if let Some(thing) = maybe {
| ^^^^^
| |
| value used here after move
| value moved here in previous iteration of loop
| ^^^^^ value moved here in previous iteration of loop
|
= note: move occurs because `maybe.0` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait