@@ -135,15 +135,12 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
135
135
borrow_id, cmt, loan_region,
136
136
bk, loan_cause) ;
137
137
138
- match opt_loan_path ( & cmt) {
139
- Some ( lp) => {
140
- let moved_value_use_kind = match loan_cause {
141
- euv:: ClosureCapture ( _) => MovedInCapture ,
142
- _ => MovedInUse ,
143
- } ;
144
- self . check_if_path_is_moved ( borrow_id, borrow_span, moved_value_use_kind, & lp) ;
145
- }
146
- None => { }
138
+ if let Some ( lp) = opt_loan_path ( & cmt) {
139
+ let moved_value_use_kind = match loan_cause {
140
+ euv:: ClosureCapture ( _) => MovedInCapture ,
141
+ _ => MovedInUse ,
142
+ } ;
143
+ self . check_if_path_is_moved ( borrow_id, borrow_span, moved_value_use_kind, & lp) ;
147
144
}
148
145
149
146
self . check_for_conflicting_loans ( borrow_id) ;
@@ -158,33 +155,29 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
158
155
debug ! ( "mutate(assignment_id={}, assignee_cmt={:?})" ,
159
156
assignment_id, assignee_cmt) ;
160
157
161
- match opt_loan_path ( & assignee_cmt) {
162
- Some ( lp) => {
163
- match mode {
164
- MutateMode :: Init | MutateMode :: JustWrite => {
165
- // In a case like `path = 1`, then path does not
166
- // have to be *FULLY* initialized, but we still
167
- // must be careful lest it contains derefs of
168
- // pointers.
169
- self . check_if_assigned_path_is_moved ( assignee_cmt. id ,
170
- assignment_span,
171
- MovedInUse ,
172
- & lp) ;
173
- }
174
- MutateMode :: WriteAndRead => {
175
- // In a case like `path += 1`, then path must be
176
- // fully initialized, since we will read it before
177
- // we write it.
178
- self . check_if_path_is_moved ( assignee_cmt. id ,
179
- assignment_span,
180
- MovedInUse ,
181
- & lp) ;
182
- }
158
+ if let Some ( lp) = opt_loan_path ( & assignee_cmt) {
159
+ match mode {
160
+ MutateMode :: Init | MutateMode :: JustWrite => {
161
+ // In a case like `path = 1`, then path does not
162
+ // have to be *FULLY* initialized, but we still
163
+ // must be careful lest it contains derefs of
164
+ // pointers.
165
+ self . check_if_assigned_path_is_moved ( assignee_cmt. id ,
166
+ assignment_span,
167
+ MovedInUse ,
168
+ & lp) ;
169
+ }
170
+ MutateMode :: WriteAndRead => {
171
+ // In a case like `path += 1`, then path must be
172
+ // fully initialized, since we will read it before
173
+ // we write it.
174
+ self . check_if_path_is_moved ( assignee_cmt. id ,
175
+ assignment_span,
176
+ MovedInUse ,
177
+ & lp) ;
183
178
}
184
179
}
185
- None => { }
186
180
}
187
-
188
181
self . check_assignment ( assignment_id, assignment_span, assignee_cmt) ;
189
182
}
190
183
@@ -601,39 +594,36 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
601
594
span : Span ,
602
595
cmt : mc:: cmt < ' tcx > ,
603
596
mode : euv:: ConsumeMode ) {
604
- match opt_loan_path ( & cmt) {
605
- Some ( lp) => {
606
- let moved_value_use_kind = match mode {
607
- euv:: Copy => {
608
- self . check_for_copy_of_frozen_path ( id, span, & lp) ;
609
- MovedInUse
610
- }
611
- euv:: Move ( _) => {
612
- match self . move_data . kind_of_move_of_path ( id, & lp) {
613
- None => {
614
- // Sometimes moves don't have a move kind;
615
- // this either means that the original move
616
- // was from something illegal to move,
617
- // or was moved from referent of an unsafe
618
- // pointer or something like that.
597
+ if let Some ( lp) = opt_loan_path ( & cmt) {
598
+ let moved_value_use_kind = match mode {
599
+ euv:: Copy => {
600
+ self . check_for_copy_of_frozen_path ( id, span, & lp) ;
601
+ MovedInUse
602
+ }
603
+ euv:: Move ( _) => {
604
+ match self . move_data . kind_of_move_of_path ( id, & lp) {
605
+ None => {
606
+ // Sometimes moves don't have a move kind;
607
+ // this either means that the original move
608
+ // was from something illegal to move,
609
+ // or was moved from referent of an unsafe
610
+ // pointer or something like that.
611
+ MovedInUse
612
+ }
613
+ Some ( move_kind) => {
614
+ self . check_for_move_of_borrowed_path ( id, span,
615
+ & lp, move_kind) ;
616
+ if move_kind == move_data:: Captured {
617
+ MovedInCapture
618
+ } else {
619
619
MovedInUse
620
620
}
621
- Some ( move_kind) => {
622
- self . check_for_move_of_borrowed_path ( id, span,
623
- & lp, move_kind) ;
624
- if move_kind == move_data:: Captured {
625
- MovedInCapture
626
- } else {
627
- MovedInUse
628
- }
629
- }
630
621
}
631
622
}
632
- } ;
623
+ }
624
+ } ;
633
625
634
- self . check_if_path_is_moved ( id, span, moved_value_use_kind, & lp) ;
635
- }
636
- None => { }
626
+ self . check_if_path_is_moved ( id, span, moved_value_use_kind, & lp) ;
637
627
}
638
628
}
639
629
0 commit comments