}
}
-pub trait DropElaborator<'a, 'tcx: 'a> : fmt::Debug {
+pub trait DropElaborator<'a, 'tcx>: fmt::Debug {
type Path : Copy + fmt::Debug;
fn patch(&mut self) -> &mut MirPatch<'tcx>;
fn body(&self) -> &'a Body<'tcx>;
- fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx>;
+ fn tcx(&self) -> TyCtxt<'tcx>;
fn param_env(&self) -> ty::ParamEnv<'tcx>;
fn drop_style(&self, path: Self::Path, mode: DropFlagMode) -> DropStyle;
}
#[derive(Debug)]
-struct DropCtxt<'l, 'b: 'l, 'tcx: 'b, D>
- where D : DropElaborator<'b, 'tcx> + 'l
+struct DropCtxt<'l, 'b, 'tcx, D>
+where
+ D: DropElaborator<'b, 'tcx>,
{
elaborator: &'l mut D,
path: D::Path,
succ: BasicBlock,
unwind: Unwind,
- bb: BasicBlock)
- where D: DropElaborator<'b, 'tcx>
+ bb: BasicBlock,
+) where
+ D: DropElaborator<'b, 'tcx>,
+ 'tcx: 'b,
{
DropCtxt {
elaborator, source_info, place, path, succ, unwind
}
impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
- where D: DropElaborator<'b, 'tcx>
+where
+ D: DropElaborator<'b, 'tcx>,
+ 'tcx: 'b,
{
fn place_ty(&self, place: &Place<'tcx>) -> Ty<'tcx> {
place.ty(self.elaborator.body(), self.tcx()).ty
}
- fn tcx(&self) -> TyCtxt<'b, 'tcx, 'tcx> {
+ fn tcx(&self) -> TyCtxt<'tcx> {
self.elaborator.tcx()
}
//
// FIXME: I think we should just control the flags externally,
// and then we do not need this machinery.
- pub fn elaborate_drop<'a>(&mut self, bb: BasicBlock) {
+ pub fn elaborate_drop(&mut self, bb: BasicBlock) {
debug!("elaborate_drop({:?})", self);
let style = self.elaborator.drop_style(self.path, DropFlagMode::Deep);
debug!("elaborate_drop({:?}): live - {:?}", self, style);
///
/// NOTE: this does not clear the master drop flag, so you need
/// to point succ/unwind on a `drop_ladder_bottom`.
- fn drop_ladder<'a>(&mut self,
- fields: Vec<(Place<'tcx>, Option<D::Path>)>,
- succ: BasicBlock,
- unwind: Unwind)
- -> (BasicBlock, Unwind)
- {
+ fn drop_ladder(
+ &mut self,
+ fields: Vec<(Place<'tcx>, Option<D::Path>)>,
+ succ: BasicBlock,
+ unwind: Unwind,
+ ) -> (BasicBlock, Unwind) {
debug!("drop_ladder({:?}, {:?})", self, fields);
let mut fields = fields;
(*normal_ladder.last().unwrap(), *unwind_ladder.last().unwrap())
}
- fn open_drop_for_tuple<'a>(&mut self, tys: &[Ty<'tcx>])
- -> BasicBlock
- {
+ fn open_drop_for_tuple(&mut self, tys: &[Ty<'tcx>]) -> BasicBlock {
debug!("open_drop_for_tuple({:?}, {:?})", self, tys);
let fields = tys.iter().enumerate().map(|(i, &ty)| {
self.drop_ladder(fields, succ, unwind).0
}
- fn open_drop_for_box<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>)
- -> BasicBlock
- {
+ fn open_drop_for_box(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock {
debug!("open_drop_for_box({:?}, {:?}, {:?})", self, adt, substs);
let interior = self.place.clone().deref();
self.drop_subpath(&interior, interior_path, succ, unwind_succ)
}
- fn open_drop_for_adt<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>)
- -> BasicBlock {
+ fn open_drop_for_adt(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock {
debug!("open_drop_for_adt({:?}, {:?}, {:?})", self, adt, substs);
if adt.variants.len() == 0 {
return self.elaborator.patch().new_block(BasicBlockData {
self.drop_flag_test_block(switch_block, succ, unwind)
}
- fn destructor_call_block<'a>(&mut self, (succ, unwind): (BasicBlock, Unwind))
- -> BasicBlock
- {
+ fn destructor_call_block(&mut self, (succ, unwind): (BasicBlock, Unwind)) -> BasicBlock {
debug!("destructor_call_block({:?}, {:?})", self, succ);
let tcx = self.tcx();
let drop_trait = tcx.lang_items().drop_trait().unwrap();
///
/// This creates a "drop ladder" that drops the needed fields of the
/// ADT, both in the success case or if one of the destructors fail.
- fn open_drop<'a>(&mut self) -> BasicBlock {
+ fn open_drop(&mut self) -> BasicBlock {
let ty = self.place_ty(self.place);
match ty.sty {
ty::Closure(def_id, substs) => {
/// if FLAG(self.path)
/// if let Some(mode) = mode: FLAG(self.path)[mode] = false
/// drop(self.place)
- fn complete_drop<'a>(&mut self,
- drop_mode: Option<DropFlagMode>,
- succ: BasicBlock,
- unwind: Unwind) -> BasicBlock
- {
+ fn complete_drop(
+ &mut self,
+ drop_mode: Option<DropFlagMode>,
+ succ: BasicBlock,
+ unwind: Unwind,
+ ) -> BasicBlock {
debug!("complete_drop({:?},{:?})", self, drop_mode);
let drop_block = self.drop_block(succ, unwind);
block
}
- fn elaborated_drop_block<'a>(&mut self) -> BasicBlock {
+ fn elaborated_drop_block(&mut self) -> BasicBlock {
debug!("elaborated_drop_block({:?})", self);
let unwind = self.unwind; // FIXME(#43234)
let succ = self.succ;
blk
}
- fn box_free_block<'a>(
+ fn box_free_block(
&mut self,
adt: &'tcx ty::AdtDef,
substs: SubstsRef<'tcx>,
self.drop_flag_test_block(block, target, unwind)
}
- fn unelaborated_free_block<'a>(
+ fn unelaborated_free_block(
&mut self,
adt: &'tcx ty::AdtDef,
substs: SubstsRef<'tcx>,
target: BasicBlock,
- unwind: Unwind
+ unwind: Unwind,
) -> BasicBlock {
let tcx = self.tcx();
let unit_temp = Place::Base(PlaceBase::Local(self.new_temp(tcx.mk_unit())));
free_block
}
- fn drop_block<'a>(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock {
+ fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock {
let block = TerminatorKind::Drop {
location: self.place.clone(),
target,
}
}
- fn new_block<'a>(&mut self,
- unwind: Unwind,
- k: TerminatorKind<'tcx>)
- -> BasicBlock
- {
+ fn new_block(&mut self, unwind: Unwind, k: TerminatorKind<'tcx>) -> BasicBlock {
self.elaborator.patch().new_block(BasicBlockData {
statements: vec![],
terminator: Some(Terminator {