@@ -705,12 +705,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
705
705
} , " (into closure)" ) ,
706
706
} ;
707
707
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
- } ;
714
708
// Annotate the use and the move in the span. Watch out for
715
709
// the case where the use and the move are the same. This
716
710
// means the use is in a loop.
@@ -720,10 +714,22 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
720
714
format ! ( "value moved{} here in previous iteration of loop{}" ,
721
715
move_note,
722
716
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
+ }
723
723
err
724
724
} 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) ) ;
727
733
err
728
734
} ;
729
735
0 commit comments