@@ -64,10 +64,7 @@ pub struct Borrows<'a, 'gcx: 'tcx, 'tcx: 'a> {
64
64
assigned_map : FxHashMap < Place < ' tcx > , FxHashSet < BorrowIndex > > ,
65
65
66
66
/// 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 > > ,
71
68
72
69
/// Every borrow has a region; this maps each such regions back to
73
70
/// its borrow-indexes.
@@ -174,7 +171,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
174
171
idx_vec : IndexVec < BorrowIndex , BorrowData < ' tcx > > ,
175
172
location_map : FxHashMap < Location , BorrowIndex > ,
176
173
assigned_map : FxHashMap < Place < ' tcx > , FxHashSet < BorrowIndex > > ,
177
- activation_map : FxHashMap < Location , BorrowIndex > ,
174
+ activation_map : FxHashMap < Location , FxHashSet < BorrowIndex > > ,
178
175
region_map : FxHashMap < Region < ' tcx > , FxHashSet < BorrowIndex > > ,
179
176
local_map : FxHashMap < mir:: Local , FxHashSet < BorrowIndex > > ,
180
177
region_span_map : FxHashMap < RegionKind , Span > ,
@@ -211,12 +208,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
211
208
let idx = self . idx_vec . push ( borrow) ;
212
209
self . location_map . insert ( location, idx) ;
213
210
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) ;
220
212
insert ( & mut self . assigned_map , assigned_place, idx) ;
221
213
insert ( & mut self . region_map , & region, idx) ;
222
214
if let Some ( local) = root_local ( borrowed_place) {
@@ -552,9 +544,11 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
552
544
location : Location ) {
553
545
// Handle activations
554
546
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
+ }
558
552
}
559
553
None => { }
560
554
}
0 commit comments