rename location field of Drop terminators to place
This commit is contained in:
parent
302fb5039b
commit
046165a807
|
@ -998,8 +998,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
bx.unreachable();
|
||||
}
|
||||
|
||||
mir::TerminatorKind::Drop { location, target, unwind } => {
|
||||
self.codegen_drop_terminator(helper, bx, location, target, unwind);
|
||||
mir::TerminatorKind::Drop { place, target, unwind } => {
|
||||
self.codegen_drop_terminator(helper, bx, place, target, unwind);
|
||||
}
|
||||
|
||||
mir::TerminatorKind::Assert { ref cond, expected, ref msg, target, cleanup } => {
|
||||
|
|
|
@ -1112,7 +1112,7 @@ pub enum TerminatorKind<'tcx> {
|
|||
Unreachable,
|
||||
|
||||
/// 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
|
||||
/// that the assignment to `P` occurs *even if* the destructor for
|
||||
|
@ -1141,7 +1141,7 @@ pub enum TerminatorKind<'tcx> {
|
|||
/// }
|
||||
/// ```
|
||||
DropAndReplace {
|
||||
location: Place<'tcx>,
|
||||
place: Place<'tcx>,
|
||||
value: Operand<'tcx>,
|
||||
target: BasicBlock,
|
||||
unwind: Option<BasicBlock>,
|
||||
|
@ -1607,9 +1607,9 @@ impl<'tcx> TerminatorKind<'tcx> {
|
|||
Abort => write!(fmt, "abort"),
|
||||
Yield { value, resume_arg, .. } => write!(fmt, "{:?} = yield({:?})", resume_arg, value),
|
||||
Unreachable => write!(fmt, "unreachable"),
|
||||
Drop { location, .. } => write!(fmt, "drop({:?})", location),
|
||||
DropAndReplace { location, value, .. } => {
|
||||
write!(fmt, "replace({:?} <- {:?})", location, value)
|
||||
Drop { place, .. } => write!(fmt, "drop({:?})", place),
|
||||
DropAndReplace { place, value, .. } => {
|
||||
write!(fmt, "replace({:?} <- {:?})", place, value)
|
||||
}
|
||||
Call { func, args, destination, .. } => {
|
||||
if let Some((destination, _)) = destination {
|
||||
|
|
|
@ -27,11 +27,11 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
|
|||
values: values.clone(),
|
||||
targets: targets.clone(),
|
||||
},
|
||||
Drop { ref location, target, unwind } => {
|
||||
Drop { location: location.fold_with(folder), target, unwind }
|
||||
Drop { ref place, target, unwind } => {
|
||||
Drop { place: place.fold_with(folder), target, unwind }
|
||||
}
|
||||
DropAndReplace { ref location, ref value, target, unwind } => DropAndReplace {
|
||||
location: location.fold_with(folder),
|
||||
DropAndReplace { ref place, ref value, target, unwind } => DropAndReplace {
|
||||
place: place.fold_with(folder),
|
||||
value: value.fold_with(folder),
|
||||
target,
|
||||
unwind,
|
||||
|
@ -97,9 +97,9 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
|
|||
SwitchInt { ref discr, switch_ty, .. } => {
|
||||
discr.visit_with(visitor) || switch_ty.visit_with(visitor)
|
||||
}
|
||||
Drop { ref location, .. } => location.visit_with(visitor),
|
||||
DropAndReplace { ref location, ref value, .. } => {
|
||||
location.visit_with(visitor) || value.visit_with(visitor)
|
||||
Drop { ref place, .. } => place.visit_with(visitor),
|
||||
DropAndReplace { ref place, ref value, .. } => {
|
||||
place.visit_with(visitor) || value.visit_with(visitor)
|
||||
}
|
||||
Yield { ref value, .. } => value.visit_with(visitor),
|
||||
Call { ref func, ref args, ref destination, .. } => {
|
||||
|
|
|
@ -449,25 +449,25 @@ macro_rules! make_mir_visitor {
|
|||
}
|
||||
|
||||
TerminatorKind::Drop {
|
||||
location,
|
||||
place,
|
||||
target: _,
|
||||
unwind: _,
|
||||
} => {
|
||||
self.visit_place(
|
||||
location,
|
||||
place,
|
||||
PlaceContext::MutatingUse(MutatingUseContext::Drop),
|
||||
source_location
|
||||
);
|
||||
}
|
||||
|
||||
TerminatorKind::DropAndReplace {
|
||||
location,
|
||||
place,
|
||||
value,
|
||||
target: _,
|
||||
unwind: _,
|
||||
} => {
|
||||
self.visit_place(
|
||||
location,
|
||||
place,
|
||||
PlaceContext::MutatingUse(MutatingUseContext::Drop),
|
||||
source_location
|
||||
);
|
||||
|
|
|
@ -119,7 +119,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
|
|||
TerminatorKind::SwitchInt { ref discr, switch_ty: _, values: _, targets: _ } => {
|
||||
self.consume_operand(location, discr);
|
||||
}
|
||||
TerminatorKind::Drop { location: drop_place, target: _, unwind: _ } => {
|
||||
TerminatorKind::Drop { place: drop_place, target: _, unwind: _ } => {
|
||||
self.access_place(
|
||||
location,
|
||||
*drop_place,
|
||||
|
@ -128,7 +128,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
|
|||
);
|
||||
}
|
||||
TerminatorKind::DropAndReplace {
|
||||
location: drop_place,
|
||||
place: drop_place,
|
||||
value: ref new_value,
|
||||
target: _,
|
||||
unwind: _,
|
||||
|
|
|
@ -663,7 +663,7 @@ impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc
|
|||
TerminatorKind::SwitchInt { ref discr, switch_ty: _, values: _, targets: _ } => {
|
||||
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;
|
||||
|
||||
// Compute the type with accurate region information.
|
||||
|
@ -692,7 +692,7 @@ impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc
|
|||
);
|
||||
}
|
||||
TerminatorKind::DropAndReplace {
|
||||
location: drop_place,
|
||||
place: drop_place,
|
||||
value: ref new_value,
|
||||
target: _,
|
||||
unwind: _,
|
||||
|
|
|
@ -1558,8 +1558,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
// no checks needed for these
|
||||
}
|
||||
|
||||
TerminatorKind::DropAndReplace { ref location, ref value, target: _, unwind: _ } => {
|
||||
let place_ty = location.ty(body, tcx).ty;
|
||||
TerminatorKind::DropAndReplace { ref place, ref value, target: _, unwind: _ } => {
|
||||
let place_ty = place.ty(body, tcx).ty;
|
||||
let rv_ty = value.ty(body, tcx);
|
||||
|
||||
let locations = term_location.to_locations();
|
||||
|
|
|
@ -70,8 +70,8 @@ impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tc
|
|||
TerminatorKind::Call { destination: Some((into, _)), .. } => {
|
||||
self.remove_never_initialized_mut_locals(*into);
|
||||
}
|
||||
TerminatorKind::DropAndReplace { location, .. } => {
|
||||
self.remove_never_initialized_mut_locals(*location);
|
||||
TerminatorKind::DropAndReplace { place, .. } => {
|
||||
self.remove_never_initialized_mut_locals(*place);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
@ -441,8 +441,8 @@ impl Direction for Forward {
|
|||
Goto { target } => propagate(target, exit_state),
|
||||
|
||||
Assert { target, cleanup: unwind, expected: _, msg: _, cond: _ }
|
||||
| Drop { target, unwind, location: _ }
|
||||
| DropAndReplace { target, unwind, value: _, location: _ }
|
||||
| Drop { target, unwind, place: _ }
|
||||
| DropAndReplace { target, unwind, value: _, place: _ }
|
||||
| FalseUnwind { real_target: target, unwind } => {
|
||||
if let Some(unwind) = unwind {
|
||||
if dead_unwinds.map_or(true, |dead| !dead.contains(bb)) {
|
||||
|
|
|
@ -189,8 +189,8 @@ where
|
|||
self.super_terminator(terminator, location);
|
||||
|
||||
match terminator.kind {
|
||||
mir::TerminatorKind::Drop { location: dropped_place, .. }
|
||||
| mir::TerminatorKind::DropAndReplace { location: dropped_place, .. } => {
|
||||
mir::TerminatorKind::Drop { place: dropped_place, .. }
|
||||
| mir::TerminatorKind::DropAndReplace { place: dropped_place, .. } => {
|
||||
// See documentation for `unsound_ignore_borrow_on_drop` for an explanation.
|
||||
if !self.ignore_borrow_on_drop {
|
||||
self.trans.gen(dropped_place.local);
|
||||
|
|
|
@ -387,13 +387,13 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
|
|||
self.gather_init(place.as_ref(), InitKind::Deep);
|
||||
}
|
||||
|
||||
TerminatorKind::Drop { location, target: _, unwind: _ } => {
|
||||
self.gather_move(location);
|
||||
TerminatorKind::Drop { place, target: _, unwind: _ } => {
|
||||
self.gather_move(place);
|
||||
}
|
||||
TerminatorKind::DropAndReplace { location, ref value, .. } => {
|
||||
self.create_move_path(location);
|
||||
TerminatorKind::DropAndReplace { place, ref value, .. } => {
|
||||
self.create_move_path(place);
|
||||
self.gather_operand(value);
|
||||
self.gather_init(location.as_ref(), InitKind::Deep);
|
||||
self.gather_init(place.as_ref(), InitKind::Deep);
|
||||
}
|
||||
TerminatorKind::Call {
|
||||
ref func,
|
||||
|
|
|
@ -91,10 +91,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
}
|
||||
}
|
||||
|
||||
Drop { location, target, unwind } => {
|
||||
let place = self.eval_place(location)?;
|
||||
Drop { place, target, unwind } => {
|
||||
let place = self.eval_place(place)?;
|
||||
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);
|
||||
self.drop_in_place(place, instance, target, unwind)?;
|
||||
|
|
|
@ -626,9 +626,9 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
|
|||
let callee_ty = self.monomorphize(callee_ty);
|
||||
visit_fn_use(self.tcx, callee_ty, true, &mut self.output);
|
||||
}
|
||||
mir::TerminatorKind::Drop { ref location, .. }
|
||||
| mir::TerminatorKind::DropAndReplace { ref location, .. } => {
|
||||
let ty = location.ty(self.body, self.tcx).ty;
|
||||
mir::TerminatorKind::Drop { ref place, .. }
|
||||
| mir::TerminatorKind::DropAndReplace { ref place, .. } => {
|
||||
let ty = place.ty(self.body, self.tcx).ty;
|
||||
let ty = self.monomorphize(ty);
|
||||
visit_drop_use(self.tcx, ty, true, self.output);
|
||||
}
|
||||
|
|
|
@ -582,7 +582,7 @@ impl CloneShimBuilder<'tcx> {
|
|||
self.block(
|
||||
vec![],
|
||||
TerminatorKind::Drop {
|
||||
location: self.tcx.mk_place_index(dest, beg),
|
||||
place: self.tcx.mk_place_index(dest, beg),
|
||||
target: BasicBlock::new(8),
|
||||
unwind: None,
|
||||
},
|
||||
|
@ -634,7 +634,7 @@ impl CloneShimBuilder<'tcx> {
|
|||
self.block(
|
||||
vec![],
|
||||
TerminatorKind::Drop {
|
||||
location: previous_field,
|
||||
place: previous_field,
|
||||
target: previous_cleanup,
|
||||
unwind: None,
|
||||
},
|
||||
|
@ -799,11 +799,7 @@ fn build_call_shim<'tcx>(
|
|||
block(
|
||||
&mut blocks,
|
||||
vec![],
|
||||
TerminatorKind::Drop {
|
||||
location: rcvr_place(),
|
||||
target: BasicBlock::new(2),
|
||||
unwind: None,
|
||||
},
|
||||
TerminatorKind::Drop { place: rcvr_place(), target: BasicBlock::new(2), unwind: None },
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
@ -814,11 +810,7 @@ fn build_call_shim<'tcx>(
|
|||
block(
|
||||
&mut blocks,
|
||||
vec![],
|
||||
TerminatorKind::Drop {
|
||||
location: rcvr_place(),
|
||||
target: BasicBlock::new(4),
|
||||
unwind: None,
|
||||
},
|
||||
TerminatorKind::Drop { place: rcvr_place(), target: BasicBlock::new(4), unwind: None },
|
||||
true,
|
||||
);
|
||||
|
||||
|
|
|
@ -64,8 +64,8 @@ fn add_moves_for_packed_drops_patch<'tcx>(
|
|||
let terminator = data.terminator();
|
||||
|
||||
match terminator.kind {
|
||||
TerminatorKind::Drop { location, .. }
|
||||
if util::is_disaligned(tcx, body, param_env, location) =>
|
||||
TerminatorKind::Drop { place, .. }
|
||||
if util::is_disaligned(tcx, body, param_env, place) =>
|
||||
{
|
||||
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,
|
||||
) {
|
||||
debug!("add_move_for_packed_drop({:?} @ {:?})", terminator, loc);
|
||||
let (location, target, unwind) = match terminator.kind {
|
||||
TerminatorKind::Drop { ref location, target, unwind } => (location, target, unwind),
|
||||
let (place, target, unwind) = match terminator.kind {
|
||||
TerminatorKind::Drop { ref place, target, unwind } => (place, target, unwind),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
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 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_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(
|
||||
loc.block,
|
||||
TerminatorKind::Drop { location: Place::from(temp), target: storage_dead_block, unwind },
|
||||
TerminatorKind::Drop { place: Place::from(temp), target: storage_dead_block, unwind },
|
||||
);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ impl Visitor<'tcx> for CheckLiveDrops<'mir, 'tcx> {
|
|||
trace!("visit_terminator: terminator={:?} location={:?}", terminator, location);
|
||||
|
||||
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;
|
||||
if !NeedsDrop::in_any_value_of_ty(self.ccx, dropped_ty) {
|
||||
return;
|
||||
|
|
|
@ -125,16 +125,15 @@ where
|
|||
// The effect of assignment to the return place in `TerminatorKind::Call` is not applied
|
||||
// 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, _>(
|
||||
self.ccx,
|
||||
&mut |l| self.qualifs_per_local.contains(l),
|
||||
value,
|
||||
);
|
||||
|
||||
if !dest.is_indirect() {
|
||||
self.assign_qualif_direct(dest, qualif);
|
||||
if !place.is_indirect() {
|
||||
self.assign_qualif_direct(place, qualif);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
// projections that cannot be `NeedsDrop`.
|
||||
TerminatorKind::Drop { location: dropped_place, .. }
|
||||
| TerminatorKind::DropAndReplace { location: dropped_place, .. } => {
|
||||
TerminatorKind::Drop { place: dropped_place, .. }
|
||||
| TerminatorKind::DropAndReplace { place: dropped_place, .. } => {
|
||||
// If we are checking live drops after drop-elaboration, don't emit duplicate
|
||||
// errors here.
|
||||
if super::post_drop_elaboration::checking_enabled(self.tcx) {
|
||||
|
|
|
@ -85,15 +85,15 @@ fn find_dead_unwinds<'tcx>(
|
|||
.iterate_to_fixpoint()
|
||||
.into_results_cursor(body);
|
||||
for (bb, bb_data) in body.basic_blocks().iter_enumerated() {
|
||||
let location = match bb_data.terminator().kind {
|
||||
TerminatorKind::Drop { ref location, unwind: Some(_), .. }
|
||||
| TerminatorKind::DropAndReplace { ref location, unwind: Some(_), .. } => location,
|
||||
let place = match bb_data.terminator().kind {
|
||||
TerminatorKind::Drop { ref place, unwind: Some(_), .. }
|
||||
| TerminatorKind::DropAndReplace { ref place, unwind: Some(_), .. } => place,
|
||||
_ => continue,
|
||||
};
|
||||
|
||||
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::Parent(..) => {
|
||||
debug!("find_dead_unwinds: has parent; skipping");
|
||||
|
@ -105,7 +105,7 @@ fn find_dead_unwinds<'tcx>(
|
|||
debug!(
|
||||
"find_dead_unwinds @ {:?}: path({:?})={:?}; init_data={:?}",
|
||||
bb,
|
||||
location,
|
||||
place,
|
||||
path,
|
||||
flow_inits.get()
|
||||
);
|
||||
|
@ -294,16 +294,16 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
|||
fn collect_drop_flags(&mut self) {
|
||||
for (bb, data) in self.body.basic_blocks().iter_enumerated() {
|
||||
let terminator = data.terminator();
|
||||
let location = match terminator.kind {
|
||||
TerminatorKind::Drop { ref location, .. }
|
||||
| TerminatorKind::DropAndReplace { ref location, .. } => location,
|
||||
let place = match terminator.kind {
|
||||
TerminatorKind::Drop { ref place, .. }
|
||||
| TerminatorKind::DropAndReplace { ref place, .. } => place,
|
||||
_ => continue,
|
||||
};
|
||||
|
||||
self.init_data.seek_before(self.body.terminator_loc(bb));
|
||||
|
||||
let path = self.move_data().rev_lookup.find(location.as_ref());
|
||||
debug!("collect_drop_flags: {:?}, place {:?} ({:?})", bb, location, path);
|
||||
let path = self.move_data().rev_lookup.find(place.as_ref());
|
||||
debug!("collect_drop_flags: {:?}, place {:?} ({:?})", bb, place, path);
|
||||
|
||||
let path = match path {
|
||||
LookupResult::Exact(e) => e,
|
||||
|
@ -315,7 +315,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
|||
terminator.source_info.span,
|
||||
"drop of untracked, uninitialized value {:?}, place {:?} ({:?})",
|
||||
bb,
|
||||
location,
|
||||
place,
|
||||
path
|
||||
);
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
|||
debug!(
|
||||
"collect_drop_flags: collecting {:?} from {:?}@{:?} - {:?}",
|
||||
child,
|
||||
location,
|
||||
place,
|
||||
path,
|
||||
(maybe_live, maybe_dead)
|
||||
);
|
||||
|
@ -346,13 +346,13 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
|||
|
||||
let resume_block = self.patch.resume_block();
|
||||
match terminator.kind {
|
||||
TerminatorKind::Drop { location, target, unwind } => {
|
||||
TerminatorKind::Drop { place, target, unwind } => {
|
||||
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(
|
||||
&mut Elaborator { ctxt: self },
|
||||
terminator.source_info,
|
||||
location,
|
||||
place,
|
||||
path,
|
||||
target,
|
||||
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);
|
||||
|
||||
self.elaborate_replace(loc, location, value, target, unwind);
|
||||
self.elaborate_replace(loc, place, value, target, unwind);
|
||||
}
|
||||
_ => continue,
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
|||
fn elaborate_replace(
|
||||
&mut self,
|
||||
loc: Location,
|
||||
location: Place<'tcx>,
|
||||
place: Place<'tcx>,
|
||||
value: &Operand<'tcx>,
|
||||
target: BasicBlock,
|
||||
unwind: Option<BasicBlock>,
|
||||
|
@ -407,7 +407,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
|||
assert!(!data.is_cleanup, "DropAndReplace in unwind path not supported");
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
|
@ -427,14 +427,14 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
|||
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) => {
|
||||
debug!("elaborate_drop_and_replace({:?}) - tracked {:?}", terminator, path);
|
||||
self.init_data.seek_before(loc);
|
||||
elaborate_drop(
|
||||
&mut Elaborator { ctxt: self },
|
||||
terminator.source_info,
|
||||
location,
|
||||
place,
|
||||
path,
|
||||
target,
|
||||
Unwind::To(unwind),
|
||||
|
@ -459,7 +459,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
|||
debug!("elaborate_drop_and_replace({:?}) - untracked {:?}", terminator, parent);
|
||||
self.patch.patch_terminator(
|
||||
bb,
|
||||
TerminatorKind::Drop { location, target, unwind: Some(unwind) },
|
||||
TerminatorKind::Drop { place, target, unwind: Some(unwind) },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
let (target, unwind, source_info) = match block_data.terminator() {
|
||||
Terminator { source_info, kind: TerminatorKind::Drop { location, target, unwind } } => {
|
||||
if let Some(local) = location.as_local() {
|
||||
Terminator { source_info, kind: TerminatorKind::Drop { place, target, unwind } } => {
|
||||
if let Some(local) = place.as_local() {
|
||||
if local == SELF_ARG {
|
||||
(target, unwind, source_info)
|
||||
} else {
|
||||
|
@ -1102,11 +1102,8 @@ fn create_generator_resume_function<'tcx>(
|
|||
fn insert_clean_drop(body: &mut Body<'_>) -> BasicBlock {
|
||||
let return_block = insert_term_block(body, TerminatorKind::Return);
|
||||
|
||||
let term = TerminatorKind::Drop {
|
||||
location: Place::from(SELF_ARG),
|
||||
target: return_block,
|
||||
unwind: None,
|
||||
};
|
||||
let term =
|
||||
TerminatorKind::Drop { place: Place::from(SELF_ARG), target: return_block, unwind: None };
|
||||
let source_info = SourceInfo::outermost(body.span);
|
||||
|
||||
// Create a block to destroy an unresumed generators. This can only destroy upvars.
|
||||
|
|
|
@ -319,13 +319,13 @@ impl Inliner<'tcx> {
|
|||
let term = blk.terminator();
|
||||
let mut is_drop = false;
|
||||
match term.kind {
|
||||
TerminatorKind::Drop { ref location, target, unwind }
|
||||
| TerminatorKind::DropAndReplace { ref location, target, unwind, .. } => {
|
||||
TerminatorKind::Drop { ref place, target, unwind }
|
||||
| TerminatorKind::DropAndReplace { ref place, target, unwind, .. } => {
|
||||
is_drop = true;
|
||||
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.
|
||||
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) {
|
||||
cost += CALL_PENALTY;
|
||||
if let Some(unwind) = unwind {
|
||||
|
|
|
@ -1186,7 +1186,7 @@ pub fn promote_candidates<'tcx>(
|
|||
_ => true,
|
||||
});
|
||||
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 promoted(index) {
|
||||
terminator.kind = TerminatorKind::Goto { target: *target };
|
||||
|
|
|
@ -349,9 +349,9 @@ fn check_terminator(
|
|||
| TerminatorKind::Resume
|
||||
| TerminatorKind::Unreachable => Ok(()),
|
||||
|
||||
TerminatorKind::Drop { location, .. } => check_place(tcx, *location, span, def_id, body),
|
||||
TerminatorKind::DropAndReplace { location, value, .. } => {
|
||||
check_place(tcx, *location, span, def_id, body)?;
|
||||
TerminatorKind::Drop { place, .. } => check_place(tcx, *place, span, def_id, body),
|
||||
TerminatorKind::DropAndReplace { place, value, .. } => {
|
||||
check_place(tcx, *place, span, def_id, body)?;
|
||||
check_operand(tcx, value, span, def_id, body)
|
||||
}
|
||||
|
||||
|
|
|
@ -238,7 +238,7 @@ where
|
|||
self.elaborator.patch().patch_terminator(
|
||||
bb,
|
||||
TerminatorKind::Drop {
|
||||
location: self.place,
|
||||
place: self.place,
|
||||
target: self.succ,
|
||||
unwind: self.unwind.into_option(),
|
||||
},
|
||||
|
@ -723,7 +723,7 @@ where
|
|||
self.elaborator.patch().patch_terminator(
|
||||
drop_block,
|
||||
TerminatorKind::Drop {
|
||||
location: tcx.mk_place_deref(ptr),
|
||||
place: tcx.mk_place_deref(ptr),
|
||||
target: loop_block,
|
||||
unwind: unwind.into_option(),
|
||||
},
|
||||
|
@ -1000,7 +1000,7 @@ where
|
|||
|
||||
fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock {
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -1037,7 +1037,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
&mut self,
|
||||
block: BasicBlock,
|
||||
span: Span,
|
||||
location: Place<'tcx>,
|
||||
place: Place<'tcx>,
|
||||
value: Operand<'tcx>,
|
||||
) -> BlockAnd<()> {
|
||||
let source_info = self.source_info(span);
|
||||
|
@ -1047,7 +1047,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
block,
|
||||
source_info,
|
||||
TerminatorKind::DropAndReplace {
|
||||
location,
|
||||
place,
|
||||
value,
|
||||
target: next_target,
|
||||
unwind: Some(diverge_target),
|
||||
|
@ -1158,7 +1158,7 @@ fn build_scope_drops<'tcx>(
|
|||
block,
|
||||
source_info,
|
||||
TerminatorKind::Drop {
|
||||
location: local.into(),
|
||||
place: local.into(),
|
||||
target: next,
|
||||
unwind: Some(unwind_to),
|
||||
},
|
||||
|
@ -1272,7 +1272,7 @@ fn build_diverge_scope<'tcx>(
|
|||
block,
|
||||
source_info(drop_data.span),
|
||||
TerminatorKind::Drop {
|
||||
location: drop_data.local.into(),
|
||||
place: drop_data.local.into(),
|
||||
target,
|
||||
unwind: None,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue