@@ -993,16 +993,23 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
993993 if let Categorization :: Local ( local_id) = err. cmt . cat {
994994 let span = self . tcx . map . span ( local_id) ;
995995 if let Ok ( snippet) = self . tcx . sess . codemap ( ) . span_to_snippet ( span) {
996- if snippet. starts_with ( "ref " ) {
997- db. span_label ( span,
998- & format ! ( "use `{}` here to make mutable" ,
999- snippet. replace( "ref " , "ref mut " ) ) ) ;
1000- } else if snippet != "self" {
1001- db. span_label ( span,
1002- & format ! ( "use `mut {}` here to make mutable" , snippet) ) ;
996+ if snippet. starts_with ( "ref mut " ) || snippet. starts_with ( "&mut " ) {
997+ db. span_label ( error_span, & format ! ( "cannot reborrow mutably" ) ) ;
998+ db. span_label ( error_span, & format ! ( "try removing `&mut` here" ) ) ;
999+ } else {
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) ) ;
1007+ }
1008+ db. span_label ( error_span, & format ! ( "cannot borrow mutably" ) ) ;
10031009 }
1010+ } else {
1011+ db. span_label ( error_span, & format ! ( "cannot borrow mutably" ) ) ;
10041012 }
1005- db. span_label ( error_span, & format ! ( "cannot borrow mutably" ) ) ;
10061013 }
10071014 }
10081015 }
0 commit comments