@@ -330,7 +330,6 @@ fn do_mir_borrowck<'tcx>(
330
330
used_mut : Default :: default ( ) ,
331
331
used_mut_upvars : SmallVec :: new ( ) ,
332
332
borrow_set : Rc :: clone ( & borrow_set) ,
333
- dominators : promoted_body. basic_blocks . dominators ( ) ,
334
333
upvars : Vec :: new ( ) ,
335
334
local_names : IndexVec :: from_elem ( None , & promoted_body. local_decls ) ,
336
335
region_names : RefCell :: default ( ) ,
@@ -359,7 +358,6 @@ fn do_mir_borrowck<'tcx>(
359
358
used_mut : Default :: default ( ) ,
360
359
used_mut_upvars : SmallVec :: new ( ) ,
361
360
borrow_set : Rc :: clone ( & borrow_set) ,
362
- dominators : body. basic_blocks . dominators ( ) ,
363
361
upvars,
364
362
local_names,
365
363
region_names : RefCell :: default ( ) ,
@@ -590,9 +588,6 @@ struct MirBorrowckCtxt<'cx, 'tcx> {
590
588
/// The set of borrows extracted from the MIR
591
589
borrow_set : Rc < BorrowSet < ' tcx > > ,
592
590
593
- /// Dominators for MIR
594
- dominators : & ' cx Dominators < BasicBlock > ,
595
-
596
591
/// Information about upvars not necessarily preserved in types or MIR
597
592
upvars : Vec < Upvar < ' tcx > > ,
598
593
@@ -1102,7 +1097,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1102
1097
1103
1098
( Read ( kind) , BorrowKind :: Unique | BorrowKind :: Mut { .. } ) => {
1104
1099
// Reading from mere reservations of mutable-borrows is OK.
1105
- if !is_active ( this. dominators , borrow, location) {
1100
+ if !is_active ( this. dominators ( ) , borrow, location) {
1106
1101
assert ! ( allow_two_phase_borrow( borrow. kind) ) ;
1107
1102
return Control :: Continue ;
1108
1103
}
@@ -2266,6 +2261,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2266
2261
fn is_upvar_field_projection ( & self , place_ref : PlaceRef < ' tcx > ) -> Option < FieldIdx > {
2267
2262
path_utils:: is_upvar_field_projection ( self . infcx . tcx , & self . upvars , place_ref, self . body ( ) )
2268
2263
}
2264
+
2265
+ fn dominators ( & self ) -> & Dominators < BasicBlock > {
2266
+ // `BasicBlocks` computes dominators on-demand and caches them.
2267
+ self . body . basic_blocks . dominators ( )
2268
+ }
2269
2269
}
2270
2270
2271
2271
mod error {
0 commit comments