Refactoring alpha-rename place (BorrowData field) to borrowed_place.

This commit is contained in:
Felix S. Klock II 2017-11-28 12:49:06 +01:00
parent e123117cb7
commit 39e126c001
3 changed files with 10 additions and 10 deletions

View file

@ -96,7 +96,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
Some(name) => format!("`{}`", name),
None => "value".to_owned(),
};
let borrow_msg = match self.describe_place(&borrow.place) {
let borrow_msg = match self.describe_place(&borrow.borrowed_place) {
Some(name) => format!("`{}`", name),
None => "value".to_owned(),
};
@ -124,7 +124,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
span,
&self.describe_place(place).unwrap_or("_".to_owned()),
self.retrieve_borrow_span(borrow),
&self.describe_place(&borrow.place).unwrap_or("_".to_owned()),
&self.describe_place(&borrow.borrowed_place).unwrap_or("_".to_owned()),
Origin::Mir,
);
@ -328,7 +328,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
) {
let end_span = borrows.opt_region_end_span(&borrow.region);
let scope_tree = borrows.scope_tree();
let root_place = self.prefixes(&borrow.place, PrefixSet::All).last().unwrap();
let root_place = self.prefixes(&borrow.borrowed_place, PrefixSet::All).last().unwrap();
match root_place {
&Place::Local(local) => {
@ -357,7 +357,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
_ => drop_span,
};
match (borrow.region, &self.describe_place(&borrow.place)) {
match (borrow.region, &self.describe_place(&borrow.borrowed_place)) {
(RegionKind::ReScope(_), Some(name)) => {
self.report_scoped_local_value_does_not_live_long_enough(
name, &scope_tree, &borrow, drop_span, borrow_span, proper_span, end_span);

View file

@ -917,7 +917,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
flow_state: &Flows<'cx, 'gcx, 'tcx>)
{
debug!("check_for_invalidation_at_exit({:?})", borrow);
let place = &borrow.place;
let place = &borrow.borrowed_place;
let root_place = self.prefixes(place, PrefixSet::All).last().unwrap();
// FIXME(nll-rfc#40): do more precise destructor tracking here. For now
@ -1792,7 +1792,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
for i in flow_state.borrows.elems_incoming() {
let borrowed = &data[i];
if self.places_conflict(&borrowed.place, place, access) {
if self.places_conflict(&borrowed.borrowed_place, place, access) {
let ctrl = op(self, i, borrowed);
if ctrl == Control::Break { return; }
}

View file

@ -49,7 +49,7 @@ pub struct Borrows<'a, 'gcx: 'tcx, 'tcx: 'a> {
}
// temporarily allow some dead fields: `kind` and `region` will be
// needed by borrowck; `place` will probably be a MovePathIndex when
// needed by borrowck; `borrowed_place` will probably be a MovePathIndex when
// that is extended to include borrowed data paths.
#[allow(dead_code)]
#[derive(Debug)]
@ -57,7 +57,7 @@ pub struct BorrowData<'tcx> {
pub(crate) location: Location,
pub(crate) kind: mir::BorrowKind,
pub(crate) region: Region<'tcx>,
pub(crate) place: mir::Place<'tcx>,
pub(crate) borrowed_place: mir::Place<'tcx>,
}
impl<'tcx> fmt::Display for BorrowData<'tcx> {
@ -69,7 +69,7 @@ impl<'tcx> fmt::Display for BorrowData<'tcx> {
};
let region = format!("{}", self.region);
let region = if region.len() > 0 { format!("{} ", region) } else { region };
write!(w, "&{}{}{:?}", region, kind, self.place)
write!(w, "&{}{}{:?}", region, kind, self.borrowed_place)
}
}
@ -131,7 +131,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
if is_unsafe_place(self.tcx, self.mir, place) { return; }
let borrow = BorrowData {
location: location, kind: kind, region: region, place: place.clone(),
location, kind, region, borrowed_place: place.clone(),
};
let idx = self.idx_vec.push(borrow);
self.location_map.insert(location, idx);