mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-11 23:33:00 +00:00
Tweak to mir borrow in a loop diagnostic
This commit is contained in:
parent
e027f5a99e
commit
a4d46b3d87
@ -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 {
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user