@@ -464,40 +464,36 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
464
464
465
465
match ( new_loan. kind , old_loan. kind ) {
466
466
( 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) ;
472
471
}
473
472
474
473
( 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) ;
480
478
}
481
479
482
480
( _, 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( ) ) ;
488
485
}
489
486
490
487
( _, _) => {
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) ;
501
497
}
502
498
}
503
499
@@ -617,11 +613,9 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
617
613
match self . analyze_restrictions_on_use ( id, copy_path, ty:: ImmBorrow ) {
618
614
UseOk => { }
619
615
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) ) ;
625
619
self . bccx . span_note (
626
620
loan_span,
627
621
& format ! ( "borrow of `{}` occurs here" ,
@@ -642,18 +636,19 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
642
636
match self . analyze_restrictions_on_use ( id, move_path, ty:: MutBorrow ) {
643
637
UseOk => { }
644
638
UseWhileBorrowed ( loan_path, loan_span) => {
645
- let err_message = match move_kind {
639
+ match move_kind {
646
640
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) ) ,
649
644
move_data:: Declared |
650
645
move_data:: MoveExpr |
651
646
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) )
654
650
} ;
655
651
656
- self . bccx . span_err ( span, & err_message[ ..] ) ;
657
652
self . bccx . span_note (
658
653
loan_span,
659
654
& format ! ( "borrow of `{}` occurs here" ,
@@ -820,10 +815,9 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
820
815
span : Span ,
821
816
loan_path : & LoanPath < ' tcx > ,
822
817
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) ) ;
827
821
self . bccx . span_note (
828
822
loan. span ,
829
823
& format ! ( "borrow of `{}` occurs here" ,
0 commit comments