Rollup merge of #61249 - spastorino:local-or-deref-local, r=oli-obk,Centril
Rename Place::local to Place::local_or_deref_local r? @oli-obk
This commit is contained in:
commit
dcfc15b23c
|
@ -2037,7 +2037,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 {
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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,
|
||||
|
|
|
@ -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(),
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue