@@ -182,7 +182,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
182182 None => { }
183183 }
184184
185- self . check_assignment ( assignment_id, assignment_span, assignee_cmt, mode ) ;
185+ self . check_assignment ( assignment_id, assignment_span, assignee_cmt) ;
186186 }
187187
188188 fn decl_without_init ( & mut self , _id : ast:: NodeId , _span : Span ) { }
@@ -782,16 +782,9 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
782782 fn check_assignment ( & self ,
783783 assignment_id : ast:: NodeId ,
784784 assignment_span : Span ,
785- assignee_cmt : mc:: cmt < ' tcx > ,
786- mode : euv:: MutateMode ) {
785+ assignee_cmt : mc:: cmt < ' tcx > ) {
787786 debug ! ( "check_assignment(assignee_cmt={:?})" , assignee_cmt) ;
788787
789- // Initializations never cause borrow errors as they only
790- // affect a fresh local.
791- if mode == euv:: Init {
792- return
793- }
794-
795788 // Check that we don't invalidate any outstanding loans
796789 if let Some ( loan_path) = opt_loan_path ( & assignee_cmt) {
797790 let scope = region:: CodeExtent :: from_node_id ( assignment_id) ;
@@ -801,17 +794,15 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
801794 } ) ;
802795 }
803796
804- // Local variables can always be assigned to, expect for reassignments
805- // of immutable variables (or assignments that invalidate loans,
806- // of course) .
797+ // Check for reassignments to (immutable) local variables. This
798+ // needs to be done here instead of in check_loans because we
799+ // depend on move data .
807800 if let mc:: cat_local( local_id) = assignee_cmt. cat {
808- if assignee_cmt. mutbl . is_mutable ( ) {
809- self . tcx ( ) . used_mut_nodes . borrow_mut ( ) . insert ( local_id) ;
810- }
811-
812801 let lp = opt_loan_path ( & assignee_cmt) . unwrap ( ) ;
813802 self . move_data . each_assignment_of ( assignment_id, & lp, |assign| {
814- if !assignee_cmt. mutbl . is_mutable ( ) {
803+ if assignee_cmt. mutbl . is_mutable ( ) {
804+ self . tcx ( ) . used_mut_nodes . borrow_mut ( ) . insert ( local_id) ;
805+ } else {
815806 self . bccx . report_reassigned_immutable_variable (
816807 assignment_span,
817808 & * lp,
0 commit comments