Skip to content

Commit 580467d

Browse files
Rename BorrowData::location to BorrowData::reserve_location
in preparation for rewritting two phase borrow support
1 parent fedce67 commit 580467d

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/librustc_mir/borrow_check/error_reporting.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
250250

251251
let new_closure_span = self.find_closure_span(span, context.loc);
252252
let span = new_closure_span.map(|(args, _)| args).unwrap_or(span);
253-
let old_closure_span = self.find_closure_span(issued_span, issued_borrow.location);
253+
let old_closure_span = self.find_closure_span(issued_span, issued_borrow.reserve_location);
254254
let issued_span = old_closure_span
255255
.map(|(args, _)| args)
256256
.unwrap_or(issued_span);
@@ -380,7 +380,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
380380
.last()
381381
.unwrap();
382382

383-
let borrow_span = self.mir.source_info(borrow.location).span;
383+
let borrow_span = self.mir.source_info(borrow.reserve_location).span;
384384
let proper_span = match *root_place {
385385
Place::Local(local) => self.mir.local_decls[local].source_info.span,
386386
_ => drop_span,
@@ -817,7 +817,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
817817

818818
// Retrieve span of given borrow from the current MIR representation
819819
pub fn retrieve_borrow_span(&self, borrow: &BorrowData) -> Span {
820-
self.mir.source_info(borrow.location).span
820+
self.mir.source_info(borrow.reserve_location).span
821821
}
822822

823823
// Retrieve type of a place for the current MIR representation

src/librustc_mir/dataflow/impls/borrows.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ impl<'a, 'gcx, 'tcx> ActiveBorrows<'a, 'gcx, 'tcx> {
111111
#[allow(dead_code)]
112112
#[derive(Debug)]
113113
pub 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

Comments
 (0)