99// except according to those terms.
1010
1111use borrow_check:: place_ext:: PlaceExt ;
12+ use borrow_check:: nll:: ToRegionVid ;
1213use dataflow:: indexes:: BorrowIndex ;
1314use dataflow:: move_paths:: MoveData ;
1415use rustc:: mir:: traversal;
1516use rustc:: mir:: visit:: {
1617 PlaceContext , Visitor , NonUseContext , MutatingUseContext , NonMutatingUseContext
1718} ;
1819use rustc:: mir:: { self , Location , Mir , Place , Local } ;
19- use rustc:: ty:: { Region , TyCtxt } ;
20+ use rustc:: ty:: { RegionVid , TyCtxt } ;
2021use rustc:: util:: nodemap:: { FxHashMap , FxHashSet } ;
2122use rustc_data_structures:: indexed_vec:: IndexVec ;
2223use rustc_data_structures:: bit_set:: BitSet ;
@@ -42,7 +43,7 @@ crate struct BorrowSet<'tcx> {
4243
4344 /// Every borrow has a region; this maps each such regions back to
4445 /// its borrow-indexes.
45- crate region_map : FxHashMap < Region < ' tcx > , FxHashSet < BorrowIndex > > ,
46+ crate region_map : FxHashMap < RegionVid , FxHashSet < BorrowIndex > > ,
4647
4748 /// Map from local to all the borrows on that local
4849 crate local_map : FxHashMap < mir:: Local , FxHashSet < BorrowIndex > > ,
@@ -77,7 +78,7 @@ crate struct BorrowData<'tcx> {
7778 /// What kind of borrow this is
7879 crate kind : mir:: BorrowKind ,
7980 /// The region for which this borrow is live
80- crate region : Region < ' tcx > ,
81+ crate region : RegionVid ,
8182 /// Place from which we are borrowing
8283 crate borrowed_place : mir:: Place < ' tcx > ,
8384 /// Place to which the borrow was stored
@@ -92,13 +93,7 @@ impl<'tcx> fmt::Display for BorrowData<'tcx> {
9293 mir:: BorrowKind :: Unique => "uniq " ,
9394 mir:: BorrowKind :: Mut { .. } => "mut " ,
9495 } ;
95- let region = self . region . to_string ( ) ;
96- let separator = if !region. is_empty ( ) {
97- " "
98- } else {
99- ""
100- } ;
101- write ! ( w, "&{}{}{}{:?}" , region, separator, kind, self . borrowed_place)
96+ write ! ( w, "&{:?} {}{:?}" , self . region, kind, self . borrowed_place)
10297 }
10398}
10499
@@ -189,7 +184,7 @@ struct GatherBorrows<'a, 'gcx: 'tcx, 'tcx: 'a> {
189184 idx_vec : IndexVec < BorrowIndex , BorrowData < ' tcx > > ,
190185 location_map : FxHashMap < Location , BorrowIndex > ,
191186 activation_map : FxHashMap < Location , Vec < BorrowIndex > > ,
192- region_map : FxHashMap < Region < ' tcx > , FxHashSet < BorrowIndex > > ,
187+ region_map : FxHashMap < RegionVid , FxHashSet < BorrowIndex > > ,
193188 local_map : FxHashMap < mir:: Local , FxHashSet < BorrowIndex > > ,
194189
195190 /// When we encounter a 2-phase borrow statement, it will always
@@ -219,6 +214,8 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
219214 return ;
220215 }
221216
217+ let region = region. to_region_vid ( ) ;
218+
222219 let borrow = BorrowData {
223220 kind,
224221 region,
@@ -230,7 +227,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
230227 let idx = self . idx_vec . push ( borrow) ;
231228 self . location_map . insert ( location, idx) ;
232229
233- self . insert_as_pending_if_two_phase ( location, & assigned_place, region , kind, idx) ;
230+ self . insert_as_pending_if_two_phase ( location, & assigned_place, kind, idx) ;
234231
235232 self . region_map . entry ( region) . or_default ( ) . insert ( idx) ;
236233 if let Some ( local) = borrowed_place. root_local ( ) {
@@ -314,7 +311,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
314311 let borrow_data = & self . idx_vec [ borrow_index] ;
315312 assert_eq ! ( borrow_data. reserve_location, location) ;
316313 assert_eq ! ( borrow_data. kind, kind) ;
317- assert_eq ! ( borrow_data. region, region) ;
314+ assert_eq ! ( borrow_data. region, region. to_region_vid ( ) ) ;
318315 assert_eq ! ( borrow_data. borrowed_place, * place) ;
319316 }
320317
@@ -347,13 +344,12 @@ impl<'a, 'gcx, 'tcx> GatherBorrows<'a, 'gcx, 'tcx> {
347344 & mut self ,
348345 start_location : Location ,
349346 assigned_place : & mir:: Place < ' tcx > ,
350- region : Region < ' tcx > ,
351347 kind : mir:: BorrowKind ,
352348 borrow_index : BorrowIndex ,
353349 ) {
354350 debug ! (
355- "Borrows::insert_as_pending_if_two_phase({:?}, {:?}, {:?}, {:?} )" ,
356- start_location, assigned_place, region , borrow_index,
351+ "Borrows::insert_as_pending_if_two_phase({:?}, {:?}, {:?})" ,
352+ start_location, assigned_place, borrow_index,
357353 ) ;
358354
359355 if !self . allow_two_phase_borrow ( kind) {
0 commit comments