@@ -997,16 +997,23 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
997997 if let Categorization :: Local ( local_id) = err. cmt . cat {
998998 let span = self . tcx . map . span ( local_id) ;
999999 if let Ok ( snippet) = self . tcx . sess . codemap ( ) . span_to_snippet ( span) {
1000- if snippet. starts_with ( "ref " ) {
1001- db. span_label ( span,
1002- & format ! ( "use `{}` here to make mutable" ,
1003- snippet. replace( "ref " , "ref mut " ) ) ) ;
1004- } else if snippet != "self" {
1005- db. span_label ( span,
1006- & format ! ( "use `mut {}` here to make mutable" , snippet) ) ;
1000+ if snippet. starts_with ( "ref mut " ) || snippet. starts_with ( "&mut " ) {
1001+ db. span_label ( error_span, & format ! ( "cannot reborrow mutably" ) ) ;
1002+ db. span_label ( error_span, & format ! ( "try removing `&mut` here" ) ) ;
1003+ } else {
1004+ if snippet. starts_with ( "ref " ) {
1005+ db. span_label ( span,
1006+ & format ! ( "use `{}` here to make mutable" ,
1007+ snippet. replace( "ref " , "ref mut " ) ) ) ;
1008+ } else if snippet != "self" {
1009+ db. span_label ( span,
1010+ & format ! ( "use `mut {}` here to make mutable" , snippet) ) ;
1011+ }
1012+ db. span_label ( error_span, & format ! ( "cannot borrow mutably" ) ) ;
10071013 }
1014+ } else {
1015+ db. span_label ( error_span, & format ! ( "cannot borrow mutably" ) ) ;
10081016 }
1009- db. span_label ( error_span, & format ! ( "cannot borrow mutably" ) ) ;
10101017 }
10111018 }
10121019 }
0 commit comments