@@ -701,7 +701,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
701701 fn bckerr_to_diag ( & self , err : & BckError < ' tcx > ) -> DiagnosticBuilder < ' a > {
702702 let span = err. span . clone ( ) ;
703703
704- let msg = match err. code {
704+ match err. code {
705705 err_mutbl => {
706706 let descr = match err. cmt . note {
707707 mc:: NoteClosureEnv ( _) | mc:: NoteUpvarRef ( _) => {
@@ -725,10 +725,11 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
725725
726726 match err. cause {
727727 MutabilityViolation => {
728- format ! ( "cannot assign to {}" , descr)
728+ struct_span_err ! ( self . tcx . sess , span , E0594 , "cannot assign to {}" , descr)
729729 }
730730 BorrowViolation ( euv:: ClosureCapture ( _) ) => {
731- format ! ( "closure cannot assign to {}" , descr)
731+ struct_span_err ! ( self . tcx. sess, span, E0595 ,
732+ "closure cannot assign to {}" , descr)
732733 }
733734 BorrowViolation ( euv:: OverloadedOperator ) |
734735 BorrowViolation ( euv:: AddrOf ) |
@@ -737,7 +738,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
737738 BorrowViolation ( euv:: AutoUnsafe ) |
738739 BorrowViolation ( euv:: ForLoop ) |
739740 BorrowViolation ( euv:: MatchDiscriminant ) => {
740- format ! ( "cannot borrow {} as mutable" , descr)
741+ struct_span_err ! ( self . tcx. sess, span, E0596 ,
742+ "cannot borrow {} as mutable" , descr)
741743 }
742744 BorrowViolation ( euv:: ClosureInvocation ) => {
743745 span_bug ! ( err. span,
@@ -752,17 +754,16 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
752754 format ! ( "`{}`" , self . loan_path_to_string( & lp) )
753755 }
754756 } ;
755- format ! ( "{} does not live long enough" , msg)
757+ struct_span_err ! ( self . tcx . sess , span , E0597 , "{} does not live long enough" , msg)
756758 }
757759 err_borrowed_pointer_too_short( ..) => {
758760 let descr = self . cmt_to_path_or_string ( & err. cmt ) ;
759- format ! ( "lifetime of {} is too short to guarantee \
760- its contents can be safely reborrowed",
761- descr)
761+ struct_span_err ! ( self . tcx. sess, span, E0598 ,
762+ "lifetime of {} is too short to guarantee \
763+ its contents can be safely reborrowed",
764+ descr)
762765 }
763- } ;
764-
765- self . struct_span_err ( span, & msg)
766+ }
766767 }
767768
768769 pub fn report_aliasability_violation ( & self ,
@@ -1169,7 +1170,7 @@ before rustc 1.16, this temporary lived longer - see issue #39283 \
11691170 if kind == ty:: ClosureKind :: Fn {
11701171 db. span_help ( self . tcx . hir . span ( upvar_id. closure_expr_id ) ,
11711172 "consider changing this closure to take \
1172- self by mutable reference") ;
1173+ self by mutable reference") ;
11731174 }
11741175 }
11751176 _ => {
0 commit comments