Skip to content

Commit

Permalink
Rename Place::local to Place::local_or_deref_local
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed May 28, 2019
1 parent 7da1185 commit 5e4d83e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/librustc/mir/mod.rs
Expand Up @@ -2040,7 +2040,7 @@ impl<'tcx> Place<'tcx> {
/// a single deref of a local.
//
// FIXME: can we safely swap the semantics of `fn base_local` below in here instead?
pub fn local(&self) -> Option<Local> {
pub fn local_or_deref_local(&self) -> Option<Local> {
match self {
Place::Base(PlaceBase::Local(local)) |
Place::Projection(box Projection {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/borrow_check/conflict_errors.rs
Expand Up @@ -1616,7 +1616,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
);

// Find the local from the operand.
let assigned_from_local = match assigned_from.local() {
let assigned_from_local = match assigned_from.local_or_deref_local() {
Some(local) => local,
None => continue,
};
Expand Down Expand Up @@ -1672,7 +1672,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
);

// Find the local from the rvalue.
let assigned_from_local = match assigned_from.local() {
let assigned_from_local = match assigned_from.local_or_deref_local() {
Some(local) => local,
None => continue,
};
Expand Down Expand Up @@ -1735,7 +1735,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
assigned_from,
);

if let Some(assigned_from_local) = assigned_from.local() {
if let Some(assigned_from_local) = assigned_from.local_or_deref_local() {
debug!(
"annotate_argument_and_return_for_borrow: assigned_from_local={:?}",
assigned_from_local,
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_mir/borrow_check/error_reporting.rs
Expand Up @@ -37,15 +37,15 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
diag: &mut DiagnosticBuilder<'_>,
) {
debug!("add_moved_or_invoked_closure_note: location={:?} place={:?}", location, place);
let mut target = place.local();
let mut target = place.local_or_deref_local();
for stmt in &self.mir[location.block].statements[location.statement_index..] {
debug!("add_moved_or_invoked_closure_note: stmt={:?} target={:?}", stmt, target);
if let StatementKind::Assign(into, box Rvalue::Use(from)) = &stmt.kind {
debug!("add_fnonce_closure_note: into={:?} from={:?}", into, from);
match from {
Operand::Copy(ref place) |
Operand::Move(ref place) if target == place.local() =>
target = into.local(),
Operand::Move(ref place) if target == place.local_or_deref_local() =>
target = into.local_or_deref_local(),
_ => {},
}
}
Expand All @@ -69,8 +69,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
if self.infcx.tcx.parent(id) == self.infcx.tcx.lang_items().fn_once_trait() {
let closure = match args.first() {
Some(Operand::Copy(ref place)) |
Some(Operand::Move(ref place)) if target == place.local() =>
place.local().unwrap(),
Some(Operand::Move(ref place)) if target == place.local_or_deref_local() =>
place.local_or_deref_local().unwrap(),
_ => return,
};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/build/expr/as_rvalue.rs
Expand Up @@ -528,7 +528,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
}) => {
// Not projected from the implicit `self` in a closure.
debug_assert!(
match base.local() {
match base.local_or_deref_local() {
Some(local) => local == Local::new(1),
None => false,
},
Expand Down
6 changes: 4 additions & 2 deletions src/librustc_mir/dataflow/impls/storage_liveness.rs
Expand Up @@ -46,8 +46,10 @@ impl<'a, 'tcx> BitDenotation<'tcx> for MaybeStorageLive<'a, 'tcx> {
sets: &mut BlockSets<'_, Local>,
loc: Location) {
match &self.mir[loc.block].terminator().kind {
TerminatorKind::Drop { location, .. } => if let Some(l) = location.local() {
sets.kill(l);
TerminatorKind::Drop { location, .. } => {
if let Some(l) = location.local_or_deref_local() {
sets.kill(l);
}
}
_ => (),
}
Expand Down

0 comments on commit 5e4d83e

Please sign in to comment.