@@ -330,7 +330,6 @@ fn do_mir_borrowck<'tcx>(
330330 used_mut : Default :: default ( ) ,
331331 used_mut_upvars : SmallVec :: new ( ) ,
332332 borrow_set : Rc :: clone ( & borrow_set) ,
333- dominators : promoted_body. basic_blocks . dominators ( ) ,
334333 upvars : Vec :: new ( ) ,
335334 local_names : IndexVec :: from_elem ( None , & promoted_body. local_decls ) ,
336335 region_names : RefCell :: default ( ) ,
@@ -359,7 +358,6 @@ fn do_mir_borrowck<'tcx>(
359358 used_mut : Default :: default ( ) ,
360359 used_mut_upvars : SmallVec :: new ( ) ,
361360 borrow_set : Rc :: clone ( & borrow_set) ,
362- dominators : body. basic_blocks . dominators ( ) ,
363361 upvars,
364362 local_names,
365363 region_names : RefCell :: default ( ) ,
@@ -590,9 +588,6 @@ struct MirBorrowckCtxt<'cx, 'tcx> {
590588 /// The set of borrows extracted from the MIR
591589 borrow_set : Rc < BorrowSet < ' tcx > > ,
592590
593- /// Dominators for MIR
594- dominators : & ' cx Dominators < BasicBlock > ,
595-
596591 /// Information about upvars not necessarily preserved in types or MIR
597592 upvars : Vec < Upvar < ' tcx > > ,
598593
@@ -1102,7 +1097,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11021097
11031098 ( Read ( kind) , BorrowKind :: Unique | BorrowKind :: Mut { .. } ) => {
11041099 // 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) {
11061101 assert ! ( allow_two_phase_borrow( borrow. kind) ) ;
11071102 return Control :: Continue ;
11081103 }
@@ -2266,6 +2261,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
22662261 fn is_upvar_field_projection ( & self , place_ref : PlaceRef < ' tcx > ) -> Option < FieldIdx > {
22672262 path_utils:: is_upvar_field_projection ( self . infcx . tcx , & self . upvars , place_ref, self . body ( ) )
22682263 }
2264+
2265+ fn dominators ( & self ) -> & Dominators < BasicBlock > {
2266+ // `BasicBlocks` computes dominators on-demand and caches them.
2267+ self . body . basic_blocks . dominators ( )
2268+ }
22692269}
22702270
22712271mod error {
0 commit comments