Skip to content

Commit

Permalink
Tweak to mir borrow in a loop diagnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Jan 3, 2018
1 parent e027f5a commit a4d46b3
Showing 2 changed files with 12 additions and 11 deletions.
18 changes: 11 additions & 7 deletions src/librustc_mir/borrow_check/error_reporting.rs
Original file line number Diff line number Diff line change
@@ -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 {
5 changes: 1 addition & 4 deletions src/test/ui/borrowck/issue-41962.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a4d46b3

Please sign in to comment.