@@ -701,7 +701,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
701
701
fn bckerr_to_diag ( & self , err : & BckError < ' tcx > ) -> DiagnosticBuilder < ' a > {
702
702
let span = err. span . clone ( ) ;
703
703
704
- let msg = match err. code {
704
+ match err. code {
705
705
err_mutbl => {
706
706
let descr = match err. cmt . note {
707
707
mc:: NoteClosureEnv ( _) | mc:: NoteUpvarRef ( _) => {
@@ -725,10 +725,11 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
725
725
726
726
match err. cause {
727
727
MutabilityViolation => {
728
- format ! ( "cannot assign to {}" , descr)
728
+ struct_span_err ! ( self . tcx . sess , span , E0594 , "cannot assign to {}" , descr)
729
729
}
730
730
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)
732
733
}
733
734
BorrowViolation ( euv:: OverloadedOperator ) |
734
735
BorrowViolation ( euv:: AddrOf ) |
@@ -737,7 +738,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
737
738
BorrowViolation ( euv:: AutoUnsafe ) |
738
739
BorrowViolation ( euv:: ForLoop ) |
739
740
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)
741
743
}
742
744
BorrowViolation ( euv:: ClosureInvocation ) => {
743
745
span_bug ! ( err. span,
@@ -752,17 +754,16 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
752
754
format ! ( "`{}`" , self . loan_path_to_string( & lp) )
753
755
}
754
756
} ;
755
- format ! ( "{} does not live long enough" , msg)
757
+ struct_span_err ! ( self . tcx . sess , span , E0597 , "{} does not live long enough" , msg)
756
758
}
757
759
err_borrowed_pointer_too_short( ..) => {
758
760
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)
762
765
}
763
- } ;
764
-
765
- self . struct_span_err ( span, & msg)
766
+ }
766
767
}
767
768
768
769
pub fn report_aliasability_violation ( & self ,
@@ -1169,7 +1170,7 @@ before rustc 1.16, this temporary lived longer - see issue #39283 \
1169
1170
if kind == ty:: ClosureKind :: Fn {
1170
1171
db. span_help ( self . tcx . hir . span ( upvar_id. closure_expr_id ) ,
1171
1172
"consider changing this closure to take \
1172
- self by mutable reference") ;
1173
+ self by mutable reference") ;
1173
1174
}
1174
1175
}
1175
1176
_ => {
0 commit comments