@@ -111,7 +111,9 @@ impl<'a, 'gcx, 'tcx> ActiveBorrows<'a, 'gcx, 'tcx> {
111111#[ allow( dead_code) ]
112112#[ derive( Debug ) ]
113113pub struct BorrowData < ' tcx > {
114- pub ( crate ) location : Location ,
114+ /// Location where the borrow reservation starts.
115+ /// In many cases, this will be equal to the activation location but not always.
116+ pub ( crate ) reserve_location : Location ,
115117 pub ( crate ) kind : mir:: BorrowKind ,
116118 pub ( crate ) region : Region < ' tcx > ,
117119 pub ( crate ) borrowed_place : mir:: Place < ' tcx > ,
@@ -209,7 +211,8 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
209211 if is_unsafe_place ( self . tcx , self . mir , borrowed_place) { return ; }
210212
211213 let borrow = BorrowData {
212- location, kind, region,
214+ reserve_location : location,
215+ kind, region,
213216 borrowed_place : borrowed_place. clone ( ) ,
214217 assigned_place : assigned_place. clone ( ) ,
215218 } ;
@@ -245,7 +248,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
245248 let mut found_it = false ;
246249 for idx in & self . region_map [ region] {
247250 let bd = & self . idx_vec [ * idx] ;
248- if bd. location == location &&
251+ if bd. reserve_location == location &&
249252 bd. kind == kind &&
250253 bd. region == region &&
251254 bd. borrowed_place == * place
@@ -277,7 +280,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
277280 pub fn scope_tree ( & self ) -> & Lrc < region:: ScopeTree > { & self . scope_tree }
278281
279282 pub fn location ( & self , idx : BorrowIndex ) -> & Location {
280- & self . borrows [ idx] . location
283+ & self . borrows [ idx] . reserve_location
281284 }
282285
283286 /// Add all borrows to the kill set, if those borrows are out of scope at `location`.
0 commit comments