rename location field of Drop terminators to place

This commit is contained in:
Ralf Jung 2020-06-10 09:56:54 +02:00
parent 302fb5039b
commit 046165a807
25 changed files with 99 additions and 111 deletions

View File

@ -998,8 +998,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
bx.unreachable(); bx.unreachable();
} }
mir::TerminatorKind::Drop { location, target, unwind } => { mir::TerminatorKind::Drop { place, target, unwind } => {
self.codegen_drop_terminator(helper, bx, location, target, unwind); self.codegen_drop_terminator(helper, bx, place, target, unwind);
} }
mir::TerminatorKind::Assert { ref cond, expected, ref msg, target, cleanup } => { mir::TerminatorKind::Assert { ref cond, expected, ref msg, target, cleanup } => {

View File

@ -1112,7 +1112,7 @@ pub enum TerminatorKind<'tcx> {
Unreachable, Unreachable,
/// Drop the `Place`. /// Drop the `Place`.
Drop { location: Place<'tcx>, target: BasicBlock, unwind: Option<BasicBlock> }, Drop { place: Place<'tcx>, target: BasicBlock, unwind: Option<BasicBlock> },
/// Drop the `Place` and assign the new value over it. This ensures /// Drop the `Place` and assign the new value over it. This ensures
/// that the assignment to `P` occurs *even if* the destructor for /// that the assignment to `P` occurs *even if* the destructor for
@ -1141,7 +1141,7 @@ pub enum TerminatorKind<'tcx> {
/// } /// }
/// ``` /// ```
DropAndReplace { DropAndReplace {
location: Place<'tcx>, place: Place<'tcx>,
value: Operand<'tcx>, value: Operand<'tcx>,
target: BasicBlock, target: BasicBlock,
unwind: Option<BasicBlock>, unwind: Option<BasicBlock>,
@ -1607,9 +1607,9 @@ impl<'tcx> TerminatorKind<'tcx> {
Abort => write!(fmt, "abort"), Abort => write!(fmt, "abort"),
Yield { value, resume_arg, .. } => write!(fmt, "{:?} = yield({:?})", resume_arg, value), Yield { value, resume_arg, .. } => write!(fmt, "{:?} = yield({:?})", resume_arg, value),
Unreachable => write!(fmt, "unreachable"), Unreachable => write!(fmt, "unreachable"),
Drop { location, .. } => write!(fmt, "drop({:?})", location), Drop { place, .. } => write!(fmt, "drop({:?})", place),
DropAndReplace { location, value, .. } => { DropAndReplace { place, value, .. } => {
write!(fmt, "replace({:?} <- {:?})", location, value) write!(fmt, "replace({:?} <- {:?})", place, value)
} }
Call { func, args, destination, .. } => { Call { func, args, destination, .. } => {
if let Some((destination, _)) = destination { if let Some((destination, _)) = destination {

View File

@ -27,11 +27,11 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
values: values.clone(), values: values.clone(),
targets: targets.clone(), targets: targets.clone(),
}, },
Drop { ref location, target, unwind } => { Drop { ref place, target, unwind } => {
Drop { location: location.fold_with(folder), target, unwind } Drop { place: place.fold_with(folder), target, unwind }
} }
DropAndReplace { ref location, ref value, target, unwind } => DropAndReplace { DropAndReplace { ref place, ref value, target, unwind } => DropAndReplace {
location: location.fold_with(folder), place: place.fold_with(folder),
value: value.fold_with(folder), value: value.fold_with(folder),
target, target,
unwind, unwind,
@ -97,9 +97,9 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
SwitchInt { ref discr, switch_ty, .. } => { SwitchInt { ref discr, switch_ty, .. } => {
discr.visit_with(visitor) || switch_ty.visit_with(visitor) discr.visit_with(visitor) || switch_ty.visit_with(visitor)
} }
Drop { ref location, .. } => location.visit_with(visitor), Drop { ref place, .. } => place.visit_with(visitor),
DropAndReplace { ref location, ref value, .. } => { DropAndReplace { ref place, ref value, .. } => {
location.visit_with(visitor) || value.visit_with(visitor) place.visit_with(visitor) || value.visit_with(visitor)
} }
Yield { ref value, .. } => value.visit_with(visitor), Yield { ref value, .. } => value.visit_with(visitor),
Call { ref func, ref args, ref destination, .. } => { Call { ref func, ref args, ref destination, .. } => {

View File

@ -449,25 +449,25 @@ macro_rules! make_mir_visitor {
} }
TerminatorKind::Drop { TerminatorKind::Drop {
location, place,
target: _, target: _,
unwind: _, unwind: _,
} => { } => {
self.visit_place( self.visit_place(
location, place,
PlaceContext::MutatingUse(MutatingUseContext::Drop), PlaceContext::MutatingUse(MutatingUseContext::Drop),
source_location source_location
); );
} }
TerminatorKind::DropAndReplace { TerminatorKind::DropAndReplace {
location, place,
value, value,
target: _, target: _,
unwind: _, unwind: _,
} => { } => {
self.visit_place( self.visit_place(
location, place,
PlaceContext::MutatingUse(MutatingUseContext::Drop), PlaceContext::MutatingUse(MutatingUseContext::Drop),
source_location source_location
); );

View File

@ -119,7 +119,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
TerminatorKind::SwitchInt { ref discr, switch_ty: _, values: _, targets: _ } => { TerminatorKind::SwitchInt { ref discr, switch_ty: _, values: _, targets: _ } => {
self.consume_operand(location, discr); self.consume_operand(location, discr);
} }
TerminatorKind::Drop { location: drop_place, target: _, unwind: _ } => { TerminatorKind::Drop { place: drop_place, target: _, unwind: _ } => {
self.access_place( self.access_place(
location, location,
*drop_place, *drop_place,
@ -128,7 +128,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
); );
} }
TerminatorKind::DropAndReplace { TerminatorKind::DropAndReplace {
location: drop_place, place: drop_place,
value: ref new_value, value: ref new_value,
target: _, target: _,
unwind: _, unwind: _,

View File

@ -663,7 +663,7 @@ impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc
TerminatorKind::SwitchInt { ref discr, switch_ty: _, values: _, targets: _ } => { TerminatorKind::SwitchInt { ref discr, switch_ty: _, values: _, targets: _ } => {
self.consume_operand(loc, (discr, span), flow_state); self.consume_operand(loc, (discr, span), flow_state);
} }
TerminatorKind::Drop { location: ref drop_place, target: _, unwind: _ } => { TerminatorKind::Drop { place: ref drop_place, target: _, unwind: _ } => {
let tcx = self.infcx.tcx; let tcx = self.infcx.tcx;
// Compute the type with accurate region information. // Compute the type with accurate region information.
@ -692,7 +692,7 @@ impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc
); );
} }
TerminatorKind::DropAndReplace { TerminatorKind::DropAndReplace {
location: drop_place, place: drop_place,
value: ref new_value, value: ref new_value,
target: _, target: _,
unwind: _, unwind: _,

View File

@ -1558,8 +1558,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
// no checks needed for these // no checks needed for these
} }
TerminatorKind::DropAndReplace { ref location, ref value, target: _, unwind: _ } => { TerminatorKind::DropAndReplace { ref place, ref value, target: _, unwind: _ } => {
let place_ty = location.ty(body, tcx).ty; let place_ty = place.ty(body, tcx).ty;
let rv_ty = value.ty(body, tcx); let rv_ty = value.ty(body, tcx);
let locations = term_location.to_locations(); let locations = term_location.to_locations();

View File

@ -70,8 +70,8 @@ impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tc
TerminatorKind::Call { destination: Some((into, _)), .. } => { TerminatorKind::Call { destination: Some((into, _)), .. } => {
self.remove_never_initialized_mut_locals(*into); self.remove_never_initialized_mut_locals(*into);
} }
TerminatorKind::DropAndReplace { location, .. } => { TerminatorKind::DropAndReplace { place, .. } => {
self.remove_never_initialized_mut_locals(*location); self.remove_never_initialized_mut_locals(*place);
} }
_ => {} _ => {}
} }

View File

@ -441,8 +441,8 @@ impl Direction for Forward {
Goto { target } => propagate(target, exit_state), Goto { target } => propagate(target, exit_state),
Assert { target, cleanup: unwind, expected: _, msg: _, cond: _ } Assert { target, cleanup: unwind, expected: _, msg: _, cond: _ }
| Drop { target, unwind, location: _ } | Drop { target, unwind, place: _ }
| DropAndReplace { target, unwind, value: _, location: _ } | DropAndReplace { target, unwind, value: _, place: _ }
| FalseUnwind { real_target: target, unwind } => { | FalseUnwind { real_target: target, unwind } => {
if let Some(unwind) = unwind { if let Some(unwind) = unwind {
if dead_unwinds.map_or(true, |dead| !dead.contains(bb)) { if dead_unwinds.map_or(true, |dead| !dead.contains(bb)) {

View File

@ -189,8 +189,8 @@ where
self.super_terminator(terminator, location); self.super_terminator(terminator, location);
match terminator.kind { match terminator.kind {
mir::TerminatorKind::Drop { location: dropped_place, .. } mir::TerminatorKind::Drop { place: dropped_place, .. }
| mir::TerminatorKind::DropAndReplace { location: dropped_place, .. } => { | mir::TerminatorKind::DropAndReplace { place: dropped_place, .. } => {
// See documentation for `unsound_ignore_borrow_on_drop` for an explanation. // See documentation for `unsound_ignore_borrow_on_drop` for an explanation.
if !self.ignore_borrow_on_drop { if !self.ignore_borrow_on_drop {
self.trans.gen(dropped_place.local); self.trans.gen(dropped_place.local);

View File

@ -387,13 +387,13 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
self.gather_init(place.as_ref(), InitKind::Deep); self.gather_init(place.as_ref(), InitKind::Deep);
} }
TerminatorKind::Drop { location, target: _, unwind: _ } => { TerminatorKind::Drop { place, target: _, unwind: _ } => {
self.gather_move(location); self.gather_move(place);
} }
TerminatorKind::DropAndReplace { location, ref value, .. } => { TerminatorKind::DropAndReplace { place, ref value, .. } => {
self.create_move_path(location); self.create_move_path(place);
self.gather_operand(value); self.gather_operand(value);
self.gather_init(location.as_ref(), InitKind::Deep); self.gather_init(place.as_ref(), InitKind::Deep);
} }
TerminatorKind::Call { TerminatorKind::Call {
ref func, ref func,

View File

@ -91,10 +91,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
} }
} }
Drop { location, target, unwind } => { Drop { place, target, unwind } => {
let place = self.eval_place(location)?; let place = self.eval_place(place)?;
let ty = place.layout.ty; let ty = place.layout.ty;
trace!("TerminatorKind::drop: {:?}, type {}", location, ty); trace!("TerminatorKind::drop: {:?}, type {}", place, ty);
let instance = Instance::resolve_drop_in_place(*self.tcx, ty); let instance = Instance::resolve_drop_in_place(*self.tcx, ty);
self.drop_in_place(place, instance, target, unwind)?; self.drop_in_place(place, instance, target, unwind)?;

View File

@ -626,9 +626,9 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
let callee_ty = self.monomorphize(callee_ty); let callee_ty = self.monomorphize(callee_ty);
visit_fn_use(self.tcx, callee_ty, true, &mut self.output); visit_fn_use(self.tcx, callee_ty, true, &mut self.output);
} }
mir::TerminatorKind::Drop { ref location, .. } mir::TerminatorKind::Drop { ref place, .. }
| mir::TerminatorKind::DropAndReplace { ref location, .. } => { | mir::TerminatorKind::DropAndReplace { ref place, .. } => {
let ty = location.ty(self.body, self.tcx).ty; let ty = place.ty(self.body, self.tcx).ty;
let ty = self.monomorphize(ty); let ty = self.monomorphize(ty);
visit_drop_use(self.tcx, ty, true, self.output); visit_drop_use(self.tcx, ty, true, self.output);
} }

View File

@ -582,7 +582,7 @@ impl CloneShimBuilder<'tcx> {
self.block( self.block(
vec![], vec![],
TerminatorKind::Drop { TerminatorKind::Drop {
location: self.tcx.mk_place_index(dest, beg), place: self.tcx.mk_place_index(dest, beg),
target: BasicBlock::new(8), target: BasicBlock::new(8),
unwind: None, unwind: None,
}, },
@ -634,7 +634,7 @@ impl CloneShimBuilder<'tcx> {
self.block( self.block(
vec![], vec![],
TerminatorKind::Drop { TerminatorKind::Drop {
location: previous_field, place: previous_field,
target: previous_cleanup, target: previous_cleanup,
unwind: None, unwind: None,
}, },
@ -799,11 +799,7 @@ fn build_call_shim<'tcx>(
block( block(
&mut blocks, &mut blocks,
vec![], vec![],
TerminatorKind::Drop { TerminatorKind::Drop { place: rcvr_place(), target: BasicBlock::new(2), unwind: None },
location: rcvr_place(),
target: BasicBlock::new(2),
unwind: None,
},
false, false,
); );
} }
@ -814,11 +810,7 @@ fn build_call_shim<'tcx>(
block( block(
&mut blocks, &mut blocks,
vec![], vec![],
TerminatorKind::Drop { TerminatorKind::Drop { place: rcvr_place(), target: BasicBlock::new(4), unwind: None },
location: rcvr_place(),
target: BasicBlock::new(4),
unwind: None,
},
true, true,
); );

View File

@ -64,8 +64,8 @@ fn add_moves_for_packed_drops_patch<'tcx>(
let terminator = data.terminator(); let terminator = data.terminator();
match terminator.kind { match terminator.kind {
TerminatorKind::Drop { location, .. } TerminatorKind::Drop { place, .. }
if util::is_disaligned(tcx, body, param_env, location) => if util::is_disaligned(tcx, body, param_env, place) =>
{ {
add_move_for_packed_drop(tcx, body, &mut patch, terminator, loc, data.is_cleanup); add_move_for_packed_drop(tcx, body, &mut patch, terminator, loc, data.is_cleanup);
} }
@ -88,13 +88,13 @@ fn add_move_for_packed_drop<'tcx>(
is_cleanup: bool, is_cleanup: bool,
) { ) {
debug!("add_move_for_packed_drop({:?} @ {:?})", terminator, loc); debug!("add_move_for_packed_drop({:?} @ {:?})", terminator, loc);
let (location, target, unwind) = match terminator.kind { let (place, target, unwind) = match terminator.kind {
TerminatorKind::Drop { ref location, target, unwind } => (location, target, unwind), TerminatorKind::Drop { ref place, target, unwind } => (place, target, unwind),
_ => unreachable!(), _ => unreachable!(),
}; };
let source_info = terminator.source_info; let source_info = terminator.source_info;
let ty = location.ty(body, tcx).ty; let ty = place.ty(body, tcx).ty;
let temp = patch.new_temp(ty, terminator.source_info.span); let temp = patch.new_temp(ty, terminator.source_info.span);
let storage_dead_block = patch.new_block(BasicBlockData { let storage_dead_block = patch.new_block(BasicBlockData {
@ -104,9 +104,9 @@ fn add_move_for_packed_drop<'tcx>(
}); });
patch.add_statement(loc, StatementKind::StorageLive(temp)); patch.add_statement(loc, StatementKind::StorageLive(temp));
patch.add_assign(loc, Place::from(temp), Rvalue::Use(Operand::Move(*location))); patch.add_assign(loc, Place::from(temp), Rvalue::Use(Operand::Move(*place)));
patch.patch_terminator( patch.patch_terminator(
loc.block, loc.block,
TerminatorKind::Drop { location: Place::from(temp), target: storage_dead_block, unwind }, TerminatorKind::Drop { place: Place::from(temp), target: storage_dead_block, unwind },
); );
} }

View File

@ -78,7 +78,7 @@ impl Visitor<'tcx> for CheckLiveDrops<'mir, 'tcx> {
trace!("visit_terminator: terminator={:?} location={:?}", terminator, location); trace!("visit_terminator: terminator={:?} location={:?}", terminator, location);
match &terminator.kind { match &terminator.kind {
mir::TerminatorKind::Drop { location: dropped_place, .. } => { mir::TerminatorKind::Drop { place: dropped_place, .. } => {
let dropped_ty = dropped_place.ty(self.body, self.tcx).ty; let dropped_ty = dropped_place.ty(self.body, self.tcx).ty;
if !NeedsDrop::in_any_value_of_ty(self.ccx, dropped_ty) { if !NeedsDrop::in_any_value_of_ty(self.ccx, dropped_ty) {
return; return;

View File

@ -125,16 +125,15 @@ where
// The effect of assignment to the return place in `TerminatorKind::Call` is not applied // The effect of assignment to the return place in `TerminatorKind::Call` is not applied
// here; that occurs in `apply_call_return_effect`. // here; that occurs in `apply_call_return_effect`.
if let mir::TerminatorKind::DropAndReplace { value, location: dest, .. } = &terminator.kind if let mir::TerminatorKind::DropAndReplace { value, place, .. } = &terminator.kind {
{
let qualif = qualifs::in_operand::<Q, _>( let qualif = qualifs::in_operand::<Q, _>(
self.ccx, self.ccx,
&mut |l| self.qualifs_per_local.contains(l), &mut |l| self.qualifs_per_local.contains(l),
value, value,
); );
if !dest.is_indirect() { if !place.is_indirect() {
self.assign_qualif_direct(dest, qualif); self.assign_qualif_direct(place, qualif);
} }
} }

View File

@ -560,8 +560,8 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
// Forbid all `Drop` terminators unless the place being dropped is a local with no // Forbid all `Drop` terminators unless the place being dropped is a local with no
// projections that cannot be `NeedsDrop`. // projections that cannot be `NeedsDrop`.
TerminatorKind::Drop { location: dropped_place, .. } TerminatorKind::Drop { place: dropped_place, .. }
| TerminatorKind::DropAndReplace { location: dropped_place, .. } => { | TerminatorKind::DropAndReplace { place: dropped_place, .. } => {
// If we are checking live drops after drop-elaboration, don't emit duplicate // If we are checking live drops after drop-elaboration, don't emit duplicate
// errors here. // errors here.
if super::post_drop_elaboration::checking_enabled(self.tcx) { if super::post_drop_elaboration::checking_enabled(self.tcx) {

View File

@ -85,15 +85,15 @@ fn find_dead_unwinds<'tcx>(
.iterate_to_fixpoint() .iterate_to_fixpoint()
.into_results_cursor(body); .into_results_cursor(body);
for (bb, bb_data) in body.basic_blocks().iter_enumerated() { for (bb, bb_data) in body.basic_blocks().iter_enumerated() {
let location = match bb_data.terminator().kind { let place = match bb_data.terminator().kind {
TerminatorKind::Drop { ref location, unwind: Some(_), .. } TerminatorKind::Drop { ref place, unwind: Some(_), .. }
| TerminatorKind::DropAndReplace { ref location, unwind: Some(_), .. } => location, | TerminatorKind::DropAndReplace { ref place, unwind: Some(_), .. } => place,
_ => continue, _ => continue,
}; };
debug!("find_dead_unwinds @ {:?}: {:?}", bb, bb_data); debug!("find_dead_unwinds @ {:?}: {:?}", bb, bb_data);
let path = match env.move_data.rev_lookup.find(location.as_ref()) { let path = match env.move_data.rev_lookup.find(place.as_ref()) {
LookupResult::Exact(e) => e, LookupResult::Exact(e) => e,
LookupResult::Parent(..) => { LookupResult::Parent(..) => {
debug!("find_dead_unwinds: has parent; skipping"); debug!("find_dead_unwinds: has parent; skipping");
@ -105,7 +105,7 @@ fn find_dead_unwinds<'tcx>(
debug!( debug!(
"find_dead_unwinds @ {:?}: path({:?})={:?}; init_data={:?}", "find_dead_unwinds @ {:?}: path({:?})={:?}; init_data={:?}",
bb, bb,
location, place,
path, path,
flow_inits.get() flow_inits.get()
); );
@ -294,16 +294,16 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
fn collect_drop_flags(&mut self) { fn collect_drop_flags(&mut self) {
for (bb, data) in self.body.basic_blocks().iter_enumerated() { for (bb, data) in self.body.basic_blocks().iter_enumerated() {
let terminator = data.terminator(); let terminator = data.terminator();
let location = match terminator.kind { let place = match terminator.kind {
TerminatorKind::Drop { ref location, .. } TerminatorKind::Drop { ref place, .. }
| TerminatorKind::DropAndReplace { ref location, .. } => location, | TerminatorKind::DropAndReplace { ref place, .. } => place,
_ => continue, _ => continue,
}; };
self.init_data.seek_before(self.body.terminator_loc(bb)); self.init_data.seek_before(self.body.terminator_loc(bb));
let path = self.move_data().rev_lookup.find(location.as_ref()); let path = self.move_data().rev_lookup.find(place.as_ref());
debug!("collect_drop_flags: {:?}, place {:?} ({:?})", bb, location, path); debug!("collect_drop_flags: {:?}, place {:?} ({:?})", bb, place, path);
let path = match path { let path = match path {
LookupResult::Exact(e) => e, LookupResult::Exact(e) => e,
@ -315,7 +315,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
terminator.source_info.span, terminator.source_info.span,
"drop of untracked, uninitialized value {:?}, place {:?} ({:?})", "drop of untracked, uninitialized value {:?}, place {:?} ({:?})",
bb, bb,
location, place,
path path
); );
} }
@ -328,7 +328,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
debug!( debug!(
"collect_drop_flags: collecting {:?} from {:?}@{:?} - {:?}", "collect_drop_flags: collecting {:?} from {:?}@{:?} - {:?}",
child, child,
location, place,
path, path,
(maybe_live, maybe_dead) (maybe_live, maybe_dead)
); );
@ -346,13 +346,13 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
let resume_block = self.patch.resume_block(); let resume_block = self.patch.resume_block();
match terminator.kind { match terminator.kind {
TerminatorKind::Drop { location, target, unwind } => { TerminatorKind::Drop { place, target, unwind } => {
self.init_data.seek_before(loc); self.init_data.seek_before(loc);
match self.move_data().rev_lookup.find(location.as_ref()) { match self.move_data().rev_lookup.find(place.as_ref()) {
LookupResult::Exact(path) => elaborate_drop( LookupResult::Exact(path) => elaborate_drop(
&mut Elaborator { ctxt: self }, &mut Elaborator { ctxt: self },
terminator.source_info, terminator.source_info,
location, place,
path, path,
target, target,
if data.is_cleanup { if data.is_cleanup {
@ -371,10 +371,10 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
} }
} }
} }
TerminatorKind::DropAndReplace { location, ref value, target, unwind } => { TerminatorKind::DropAndReplace { place, ref value, target, unwind } => {
assert!(!data.is_cleanup); assert!(!data.is_cleanup);
self.elaborate_replace(loc, location, value, target, unwind); self.elaborate_replace(loc, place, value, target, unwind);
} }
_ => continue, _ => continue,
} }
@ -396,7 +396,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
fn elaborate_replace( fn elaborate_replace(
&mut self, &mut self,
loc: Location, loc: Location,
location: Place<'tcx>, place: Place<'tcx>,
value: &Operand<'tcx>, value: &Operand<'tcx>,
target: BasicBlock, target: BasicBlock,
unwind: Option<BasicBlock>, unwind: Option<BasicBlock>,
@ -407,7 +407,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
assert!(!data.is_cleanup, "DropAndReplace in unwind path not supported"); assert!(!data.is_cleanup, "DropAndReplace in unwind path not supported");
let assign = Statement { let assign = Statement {
kind: StatementKind::Assign(box (location, Rvalue::Use(value.clone()))), kind: StatementKind::Assign(box (place, Rvalue::Use(value.clone()))),
source_info: terminator.source_info, source_info: terminator.source_info,
}; };
@ -427,14 +427,14 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
is_cleanup: false, is_cleanup: false,
}); });
match self.move_data().rev_lookup.find(location.as_ref()) { match self.move_data().rev_lookup.find(place.as_ref()) {
LookupResult::Exact(path) => { LookupResult::Exact(path) => {
debug!("elaborate_drop_and_replace({:?}) - tracked {:?}", terminator, path); debug!("elaborate_drop_and_replace({:?}) - tracked {:?}", terminator, path);
self.init_data.seek_before(loc); self.init_data.seek_before(loc);
elaborate_drop( elaborate_drop(
&mut Elaborator { ctxt: self }, &mut Elaborator { ctxt: self },
terminator.source_info, terminator.source_info,
location, place,
path, path,
target, target,
Unwind::To(unwind), Unwind::To(unwind),
@ -459,7 +459,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
debug!("elaborate_drop_and_replace({:?}) - untracked {:?}", terminator, parent); debug!("elaborate_drop_and_replace({:?}) - untracked {:?}", terminator, parent);
self.patch.patch_terminator( self.patch.patch_terminator(
bb, bb,
TerminatorKind::Drop { location, target, unwind: Some(unwind) }, TerminatorKind::Drop { place, target, unwind: Some(unwind) },
); );
} }
} }

View File

@ -835,8 +835,8 @@ fn elaborate_generator_drops<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, body: &mut
for (block, block_data) in body.basic_blocks().iter_enumerated() { for (block, block_data) in body.basic_blocks().iter_enumerated() {
let (target, unwind, source_info) = match block_data.terminator() { let (target, unwind, source_info) = match block_data.terminator() {
Terminator { source_info, kind: TerminatorKind::Drop { location, target, unwind } } => { Terminator { source_info, kind: TerminatorKind::Drop { place, target, unwind } } => {
if let Some(local) = location.as_local() { if let Some(local) = place.as_local() {
if local == SELF_ARG { if local == SELF_ARG {
(target, unwind, source_info) (target, unwind, source_info)
} else { } else {
@ -1102,11 +1102,8 @@ fn create_generator_resume_function<'tcx>(
fn insert_clean_drop(body: &mut Body<'_>) -> BasicBlock { fn insert_clean_drop(body: &mut Body<'_>) -> BasicBlock {
let return_block = insert_term_block(body, TerminatorKind::Return); let return_block = insert_term_block(body, TerminatorKind::Return);
let term = TerminatorKind::Drop { let term =
location: Place::from(SELF_ARG), TerminatorKind::Drop { place: Place::from(SELF_ARG), target: return_block, unwind: None };
target: return_block,
unwind: None,
};
let source_info = SourceInfo::outermost(body.span); let source_info = SourceInfo::outermost(body.span);
// Create a block to destroy an unresumed generators. This can only destroy upvars. // Create a block to destroy an unresumed generators. This can only destroy upvars.

View File

@ -319,13 +319,13 @@ impl Inliner<'tcx> {
let term = blk.terminator(); let term = blk.terminator();
let mut is_drop = false; let mut is_drop = false;
match term.kind { match term.kind {
TerminatorKind::Drop { ref location, target, unwind } TerminatorKind::Drop { ref place, target, unwind }
| TerminatorKind::DropAndReplace { ref location, target, unwind, .. } => { | TerminatorKind::DropAndReplace { ref place, target, unwind, .. } => {
is_drop = true; is_drop = true;
work_list.push(target); work_list.push(target);
// If the location doesn't actually need dropping, treat it like // If the place doesn't actually need dropping, treat it like
// a regular goto. // a regular goto.
let ty = location.ty(callee_body, tcx).subst(tcx, callsite.substs).ty; let ty = place.ty(callee_body, tcx).subst(tcx, callsite.substs).ty;
if ty.needs_drop(tcx, param_env) { if ty.needs_drop(tcx, param_env) {
cost += CALL_PENALTY; cost += CALL_PENALTY;
if let Some(unwind) = unwind { if let Some(unwind) = unwind {

View File

@ -1186,7 +1186,7 @@ pub fn promote_candidates<'tcx>(
_ => true, _ => true,
}); });
let terminator = block.terminator_mut(); let terminator = block.terminator_mut();
if let TerminatorKind::Drop { location: place, target, .. } = &terminator.kind { if let TerminatorKind::Drop { place, target, .. } = &terminator.kind {
if let Some(index) = place.as_local() { if let Some(index) = place.as_local() {
if promoted(index) { if promoted(index) {
terminator.kind = TerminatorKind::Goto { target: *target }; terminator.kind = TerminatorKind::Goto { target: *target };

View File

@ -349,9 +349,9 @@ fn check_terminator(
| TerminatorKind::Resume | TerminatorKind::Resume
| TerminatorKind::Unreachable => Ok(()), | TerminatorKind::Unreachable => Ok(()),
TerminatorKind::Drop { location, .. } => check_place(tcx, *location, span, def_id, body), TerminatorKind::Drop { place, .. } => check_place(tcx, *place, span, def_id, body),
TerminatorKind::DropAndReplace { location, value, .. } => { TerminatorKind::DropAndReplace { place, value, .. } => {
check_place(tcx, *location, span, def_id, body)?; check_place(tcx, *place, span, def_id, body)?;
check_operand(tcx, value, span, def_id, body) check_operand(tcx, value, span, def_id, body)
} }

View File

@ -238,7 +238,7 @@ where
self.elaborator.patch().patch_terminator( self.elaborator.patch().patch_terminator(
bb, bb,
TerminatorKind::Drop { TerminatorKind::Drop {
location: self.place, place: self.place,
target: self.succ, target: self.succ,
unwind: self.unwind.into_option(), unwind: self.unwind.into_option(),
}, },
@ -723,7 +723,7 @@ where
self.elaborator.patch().patch_terminator( self.elaborator.patch().patch_terminator(
drop_block, drop_block,
TerminatorKind::Drop { TerminatorKind::Drop {
location: tcx.mk_place_deref(ptr), place: tcx.mk_place_deref(ptr),
target: loop_block, target: loop_block,
unwind: unwind.into_option(), unwind: unwind.into_option(),
}, },
@ -1000,7 +1000,7 @@ where
fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock { fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock {
let block = let block =
TerminatorKind::Drop { location: self.place, target, unwind: unwind.into_option() }; TerminatorKind::Drop { place: self.place, target, unwind: unwind.into_option() };
self.new_block(unwind, block) self.new_block(unwind, block)
} }

View File

@ -1037,7 +1037,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
&mut self, &mut self,
block: BasicBlock, block: BasicBlock,
span: Span, span: Span,
location: Place<'tcx>, place: Place<'tcx>,
value: Operand<'tcx>, value: Operand<'tcx>,
) -> BlockAnd<()> { ) -> BlockAnd<()> {
let source_info = self.source_info(span); let source_info = self.source_info(span);
@ -1047,7 +1047,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block, block,
source_info, source_info,
TerminatorKind::DropAndReplace { TerminatorKind::DropAndReplace {
location, place,
value, value,
target: next_target, target: next_target,
unwind: Some(diverge_target), unwind: Some(diverge_target),
@ -1158,7 +1158,7 @@ fn build_scope_drops<'tcx>(
block, block,
source_info, source_info,
TerminatorKind::Drop { TerminatorKind::Drop {
location: local.into(), place: local.into(),
target: next, target: next,
unwind: Some(unwind_to), unwind: Some(unwind_to),
}, },
@ -1272,7 +1272,7 @@ fn build_diverge_scope<'tcx>(
block, block,
source_info(drop_data.span), source_info(drop_data.span),
TerminatorKind::Drop { TerminatorKind::Drop {
location: drop_data.local.into(), place: drop_data.local.into(),
target, target,
unwind: None, unwind: None,
}, },