@@ -648,13 +648,17 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
648
648
copy_path : & LoanPath < ' tcx > ) {
649
649
match self . analyze_restrictions_on_use ( id, copy_path, ty:: ImmBorrow ) {
650
650
UseOk => { }
651
- UseWhileBorrowed ( loan_path , loan_span) => {
651
+ UseWhileBorrowed ( _ , loan_span) => {
652
652
struct_span_err ! ( self . bccx, span, E0503 ,
653
653
"cannot use `{}` because it was mutably borrowed" ,
654
654
& self . bccx. loan_path_to_string( copy_path) )
655
- . span_note ( loan_span,
656
- & format ! ( "borrow of `{}` occurs here" ,
657
- & self . bccx. loan_path_to_string( & loan_path) )
655
+ . span_label ( loan_span,
656
+ & format ! ( "mutable borrow of `{}` occurs here" ,
657
+ & self . bccx. loan_path_to_string( copy_path) )
658
+ )
659
+ . span_label ( span,
660
+ & format ! ( "use of `{}` occurs here" ,
661
+ & self . bccx. loan_path_to_string( copy_path) )
658
662
)
659
663
. emit ( ) ;
660
664
}
@@ -671,25 +675,38 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
671
675
// loans are incompatible with that.
672
676
match self . analyze_restrictions_on_use ( id, move_path, ty:: MutBorrow ) {
673
677
UseOk => { }
674
- UseWhileBorrowed ( loan_path , loan_span) => {
678
+ UseWhileBorrowed ( _ , loan_span) => {
675
679
let mut err = match move_kind {
676
- move_data:: Captured =>
680
+ move_data:: Captured => {
677
681
struct_span_err ! ( self . bccx, span, E0504 ,
678
682
"cannot move `{}` into closure because it is borrowed" ,
679
- & self . bccx. loan_path_to_string( move_path) ) ,
683
+ & self . bccx. loan_path_to_string( move_path) )
684
+ . span_label (
685
+ loan_span,
686
+ & format ! ( "borrow of `{}` occurs here" ,
687
+ & self . bccx. loan_path_to_string( move_path) ) )
688
+ . span_label (
689
+ span,
690
+ & format ! ( "move of `{}` occurs here" ,
691
+ & self . bccx. loan_path_to_string( move_path) ) )
692
+ }
680
693
move_data:: Declared |
681
694
move_data:: MoveExpr |
682
- move_data:: MovePat =>
695
+ move_data:: MovePat => {
683
696
struct_span_err ! ( self . bccx, span, E0505 ,
684
697
"cannot move out of `{}` because it is borrowed" ,
685
698
& self . bccx. loan_path_to_string( move_path) )
699
+ . span_label (
700
+ loan_span,
701
+ & format ! ( "borrow of `{}` occurs here" ,
702
+ & self . bccx. loan_path_to_string( move_path) ) )
703
+ . span_label (
704
+ span,
705
+ & format ! ( "move out of `{}` occurs here" ,
706
+ & self . bccx. loan_path_to_string( move_path) ) )
707
+ }
686
708
} ;
687
709
688
- err. span_note (
689
- loan_span,
690
- & format ! ( "borrow of `{}` occurs here" ,
691
- & self . bccx. loan_path_to_string( & loan_path) )
692
- ) ;
693
710
err. emit ( ) ;
694
711
}
695
712
}
@@ -855,9 +872,12 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
855
872
struct_span_err ! ( self . bccx, span, E0506 ,
856
873
"cannot assign to `{}` because it is borrowed" ,
857
874
self . bccx. loan_path_to_string( loan_path) )
858
- . span_note ( loan. span ,
875
+ . span_label ( loan. span ,
859
876
& format ! ( "borrow of `{}` occurs here" ,
860
877
self . bccx. loan_path_to_string( loan_path) ) )
878
+ . span_label ( span,
879
+ & format ! ( "assignment to `{}` occurs here" ,
880
+ self . bccx. loan_path_to_string( loan_path) ) )
861
881
. emit ( ) ;
862
882
}
863
883
}
0 commit comments