Skip to content

Commit

Permalink
Refactoring alpha-rename place (BorrowData field) to `borrowed_pl…
Browse files Browse the repository at this point in the history
…ace`.
  • Loading branch information
pnkfelix committed Dec 13, 2017
1 parent e123117 commit 39e126c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/librustc_mir/borrow_check/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
Expand Down Expand Up @@ -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,
);

Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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; }
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_mir/dataflow/impls/borrows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ 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)]
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> {
Expand All @@ -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)
}
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 39e126c

Please sign in to comment.