@@ -1267,36 +1267,30 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1267
1267
// Two-phase borrow support: For each activation that is newly
1268
1268
// generated at this statement, check if it interferes with
1269
1269
// another borrow.
1270
- let domain = flow_state. borrows . operator ( ) ;
1271
- let data = domain. borrows ( ) ;
1272
- flow_state. borrows . each_gen_bit ( |gen| {
1273
- if gen. is_activation ( ) {
1274
- let borrow_index = gen. borrow_index ( ) ;
1275
- let borrow = & data[ borrow_index] ;
1276
- // currently the flow analysis registers
1277
- // activations for both mutable and immutable
1278
- // borrows. So make sure we are talking about a
1279
- // mutable borrow before we check it.
1280
- match borrow. kind {
1281
- BorrowKind :: Shared => return ,
1282
- BorrowKind :: Unique | BorrowKind :: Mut { .. } => { }
1283
- }
1284
-
1285
- self . access_place (
1286
- ContextKind :: Activation . new ( location) ,
1287
- ( & borrow. borrowed_place , span) ,
1288
- (
1289
- Deep ,
1290
- Activation ( WriteKind :: MutableBorrow ( borrow. kind ) , borrow_index) ,
1291
- ) ,
1292
- LocalMutationIsAllowed :: No ,
1293
- flow_state,
1294
- ) ;
1295
- // We do not need to call `check_if_path_or_subpath_is_moved`
1296
- // again, as we already called it when we made the
1297
- // initial reservation.
1298
- }
1299
- } ) ;
1270
+ let borrows = flow_state. borrows . operator ( ) ;
1271
+ for & borrow_index in borrows. activations_at_location ( location) {
1272
+ let borrow = & borrows. borrows ( ) [ borrow_index] ;
1273
+
1274
+ // only mutable borrows should be 2-phase
1275
+ assert ! ( match borrow. kind {
1276
+ BorrowKind :: Shared => false ,
1277
+ BorrowKind :: Unique | BorrowKind :: Mut { .. } => true ,
1278
+ } ) ;
1279
+
1280
+ self . access_place (
1281
+ ContextKind :: Activation . new ( location) ,
1282
+ ( & borrow. borrowed_place , span) ,
1283
+ (
1284
+ Deep ,
1285
+ Activation ( WriteKind :: MutableBorrow ( borrow. kind ) , borrow_index) ,
1286
+ ) ,
1287
+ LocalMutationIsAllowed :: No ,
1288
+ flow_state,
1289
+ ) ;
1290
+ // We do not need to call `check_if_path_or_subpath_is_moved`
1291
+ // again, as we already called it when we made the
1292
+ // initial reservation.
1293
+ }
1300
1294
}
1301
1295
}
1302
1296
0 commit comments