@@ -64,10 +64,7 @@ pub struct Borrows<'a, 'gcx: 'tcx, 'tcx: 'a> {
6464 assigned_map : FxHashMap < Place < ' tcx > , FxHashSet < BorrowIndex > > ,
6565
6666 /// Locations which activate borrows.
67- /// NOTE: A given location may activate more than one borrow in the future
68- /// when more general two-phase borrow support is introduced, but for now we
69- /// only need to store one borrow index
70- activation_map : FxHashMap < Location , BorrowIndex > ,
67+ activation_map : FxHashMap < Location , FxHashSet < BorrowIndex > > ,
7168
7269 /// Every borrow has a region; this maps each such regions back to
7370 /// its borrow-indexes.
@@ -174,7 +171,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
174171 idx_vec : IndexVec < BorrowIndex , BorrowData < ' tcx > > ,
175172 location_map : FxHashMap < Location , BorrowIndex > ,
176173 assigned_map : FxHashMap < Place < ' tcx > , FxHashSet < BorrowIndex > > ,
177- activation_map : FxHashMap < Location , BorrowIndex > ,
174+ activation_map : FxHashMap < Location , FxHashSet < BorrowIndex > > ,
178175 region_map : FxHashMap < Region < ' tcx > , FxHashSet < BorrowIndex > > ,
179176 local_map : FxHashMap < mir:: Local , FxHashSet < BorrowIndex > > ,
180177 region_span_map : FxHashMap < RegionKind , Span > ,
@@ -211,12 +208,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
211208 let idx = self . idx_vec . push ( borrow) ;
212209 self . location_map . insert ( location, idx) ;
213210
214- // This assert is a good sanity check until more general 2-phase borrow
215- // support is introduced. See NOTE on the activation_map field for more
216- assert ! ( !self . activation_map. contains_key( & activate_location) ,
217- "More than one activation introduced at the same location." ) ;
218- self . activation_map . insert ( activate_location, idx) ;
219-
211+ insert ( & mut self . activation_map , & activate_location, idx) ;
220212 insert ( & mut self . assigned_map , assigned_place, idx) ;
221213 insert ( & mut self . region_map , & region, idx) ;
222214 if let Some ( local) = root_local ( borrowed_place) {
@@ -552,9 +544,11 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
552544 location : Location ) {
553545 // Handle activations
554546 match self . activation_map . get ( & location) {
555- Some ( & activated) => {
556- debug ! ( "activating borrow {:?}" , activated) ;
557- sets. gen ( & ReserveOrActivateIndex :: active ( activated) )
547+ Some ( activations) => {
548+ for activated in activations {
549+ debug ! ( "activating borrow {:?}" , activated) ;
550+ sets. gen ( & ReserveOrActivateIndex :: active ( * activated) )
551+ }
558552 }
559553 None => { }
560554 }
0 commit comments