Skip to content

Commit 6c506d4

Browse files
committed
Address review comments: make label shorter
1 parent be6734a commit 6c506d4

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/librustc_borrowck/borrowck/mod.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -705,12 +705,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
705705
}, " (into closure)"),
706706
};
707707

708-
let extra_move_label = if need_note {
709-
format!(" because it has type `{}`, which does not implement the `Copy` trait",
710-
moved_lp.ty)
711-
} else {
712-
String::new()
713-
};
714708
// Annotate the use and the move in the span. Watch out for
715709
// the case where the use and the move are the same. This
716710
// means the use is in a loop.
@@ -720,10 +714,22 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
720714
format!("value moved{} here in previous iteration of loop{}",
721715
move_note,
722716
extra_move_label));
717+
718+
if need_note {
719+
err.note(&format!("value moved because it has type `{}`, \
720+
which does not implement the `Copy` trait",
721+
moved_lp.ty)
722+
}
723723
err
724724
} else {
725-
err.span_label(use_span, format!("value {} here after move", verb_participle))
726-
.span_label(move_span, format!("value moved{} here{}", move_note, extra_move_label));
725+
err.span_label(use_span, format!("value {} here after move", verb_participle));
726+
let extra_move_label = if need_note {
727+
&format!(" because it has type `{}`, which does not implement the `Copy` trait",
728+
moved_lp.ty)
729+
} else {
730+
""
731+
};
732+
err.span_label(move_span,format!("value moved{} here{}", move_note, extra_move_label));
727733
err
728734
};
729735

src/test/ui/borrowck/issue-41962.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0`
1010
--> $DIR/issue-41962.rs:15:21
1111
|
1212
15 | if let Some(thing) = maybe {
13-
| ^^^^^ value moved here in previous iteration of loop because it has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
13+
| ^^^^^ value moved here in previous iteration of loop
14+
= note: value moved because it has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
1415

1516
error: aborting due to 2 previous errors
1617

0 commit comments

Comments
 (0)