@@ -464,40 +464,36 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
464464
465465 match ( new_loan. kind , old_loan. kind ) {
466466 ( ty:: MutBorrow , ty:: MutBorrow ) => {
467- self . bccx . span_err (
468- new_loan. span ,
469- & format ! ( "cannot borrow `{}`{} as mutable \
470- more than once at a time",
471- nl, new_loan_msg) )
467+ span_err ! ( self . bccx, new_loan. span, E0499 ,
468+ "cannot borrow `{}`{} as mutable \
469+ more than once at a time",
470+ nl, new_loan_msg) ;
472471 }
473472
474473 ( ty:: UniqueImmBorrow , _) => {
475- self . bccx . span_err (
476- new_loan. span ,
477- & format ! ( "closure requires unique access to `{}` \
478- but {} is already borrowed{}",
479- nl, ol_pronoun, old_loan_msg) ) ;
474+ span_err ! ( self . bccx, new_loan. span, E0500 ,
475+ "closure requires unique access to `{}` \
476+ but {} is already borrowed{}",
477+ nl, ol_pronoun, old_loan_msg) ;
480478 }
481479
482480 ( _, ty:: UniqueImmBorrow ) => {
483- self . bccx . span_err (
484- new_loan. span ,
485- & format ! ( "cannot borrow `{}`{} as {} because \
486- previous closure requires unique access",
487- nl, new_loan_msg, new_loan. kind. to_user_str( ) ) ) ;
481+ span_err ! ( self . bccx, new_loan. span, E0501 ,
482+ "cannot borrow `{}`{} as {} because \
483+ previous closure requires unique access",
484+ nl, new_loan_msg, new_loan. kind. to_user_str( ) ) ;
488485 }
489486
490487 ( _, _) => {
491- self . bccx . span_err (
492- new_loan. span ,
493- & format ! ( "cannot borrow `{}`{} as {} because \
494- {} is also borrowed as {}{}",
495- nl,
496- new_loan_msg,
497- new_loan. kind. to_user_str( ) ,
498- ol_pronoun,
499- old_loan. kind. to_user_str( ) ,
500- old_loan_msg) ) ;
488+ span_err ! ( self . bccx, new_loan. span, E0502 ,
489+ "cannot borrow `{}`{} as {} because \
490+ {} is also borrowed as {}{}",
491+ nl,
492+ new_loan_msg,
493+ new_loan. kind. to_user_str( ) ,
494+ ol_pronoun,
495+ old_loan. kind. to_user_str( ) ,
496+ old_loan_msg) ;
501497 }
502498 }
503499
@@ -617,11 +613,9 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
617613 match self . analyze_restrictions_on_use ( id, copy_path, ty:: ImmBorrow ) {
618614 UseOk => { }
619615 UseWhileBorrowed ( loan_path, loan_span) => {
620- self . bccx . span_err (
621- span,
622- & format ! ( "cannot use `{}` because it was mutably borrowed" ,
623- & self . bccx. loan_path_to_string( copy_path) )
624- ) ;
616+ span_err ! ( self . bccx, span, E0503 ,
617+ "cannot use `{}` because it was mutably borrowed" ,
618+ & self . bccx. loan_path_to_string( copy_path) ) ;
625619 self . bccx . span_note (
626620 loan_span,
627621 & format ! ( "borrow of `{}` occurs here" ,
@@ -642,18 +636,19 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
642636 match self . analyze_restrictions_on_use ( id, move_path, ty:: MutBorrow ) {
643637 UseOk => { }
644638 UseWhileBorrowed ( loan_path, loan_span) => {
645- let err_message = match move_kind {
639+ match move_kind {
646640 move_data:: Captured =>
647- format ! ( "cannot move `{}` into closure because it is borrowed" ,
648- & self . bccx. loan_path_to_string( move_path) ) ,
641+ span_err ! ( self . bccx, span, E0504 ,
642+ "cannot move `{}` into closure because it is borrowed" ,
643+ & self . bccx. loan_path_to_string( move_path) ) ,
649644 move_data:: Declared |
650645 move_data:: MoveExpr |
651646 move_data:: MovePat =>
652- format ! ( "cannot move out of `{}` because it is borrowed" ,
653- & self . bccx. loan_path_to_string( move_path) )
647+ span_err ! ( self . bccx, span, E0505 ,
648+ "cannot move out of `{}` because it is borrowed" ,
649+ & self . bccx. loan_path_to_string( move_path) )
654650 } ;
655651
656- self . bccx . span_err ( span, & err_message[ ..] ) ;
657652 self . bccx . span_note (
658653 loan_span,
659654 & format ! ( "borrow of `{}` occurs here" ,
@@ -820,10 +815,9 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
820815 span : Span ,
821816 loan_path : & LoanPath < ' tcx > ,
822817 loan : & Loan ) {
823- self . bccx . span_err (
824- span,
825- & format ! ( "cannot assign to `{}` because it is borrowed" ,
826- self . bccx. loan_path_to_string( loan_path) ) ) ;
818+ span_err ! ( self . bccx, span, E0506 ,
819+ "cannot assign to `{}` because it is borrowed" ,
820+ self . bccx. loan_path_to_string( loan_path) ) ;
827821 self . bccx . span_note (
828822 loan. span ,
829823 & format ! ( "borrow of `{}` occurs here" ,
0 commit comments