Skip to content

Commit d49b50f

Browse files
committed
Resolve Drop calls
1 parent 1da4efb commit d49b50f

File tree

1 file changed

+39
-1
lines changed
  • frontend/exporter/src/types

1 file changed

+39
-1
lines changed

frontend/exporter/src/types/mir.rs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,38 @@ fn translate_terminator_kind_call<'tcx, S: BaseState<'tcx> + HasMir<'tcx> + HasO
489489
}
490490
}
491491

492+
#[cfg(feature = "rustc")]
493+
fn translate_terminator_kind_drop<'tcx, S: BaseState<'tcx> + HasMir<'tcx> + HasOwnerId>(
494+
s: &S,
495+
terminator: &rustc_middle::mir::TerminatorKind<'tcx>,
496+
) -> TerminatorKind {
497+
let tcx = s.base().tcx;
498+
let mir::TerminatorKind::Drop {
499+
place,
500+
target,
501+
unwind,
502+
..
503+
} = terminator
504+
else {
505+
unreachable!()
506+
};
507+
508+
let local_decls = &s.mir().local_decls;
509+
let place_ty = place.ty(local_decls, tcx).ty;
510+
let drop_trait = tcx.lang_items().drop_trait().unwrap();
511+
let impl_expr = solve_trait(
512+
s,
513+
ty::Binder::dummy(ty::TraitRef::new(tcx, drop_trait, [place_ty])),
514+
);
515+
516+
TerminatorKind::Drop {
517+
place: place.sinto(s),
518+
impl_expr,
519+
target: target.sinto(s),
520+
unwind: unwind.sinto(s),
521+
}
522+
}
523+
492524
// We don't use the LitIntType on purpose (we don't want the "unsuffixed" case)
493525
#[derive_group(Serializers)]
494526
#[derive(Clone, Copy, Debug, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord)]
@@ -599,11 +631,17 @@ pub enum TerminatorKind {
599631
},
600632
Return,
601633
Unreachable,
634+
#[custom_arm(
635+
x @ rustc_middle::mir::TerminatorKind::Drop { .. } => {
636+
translate_terminator_kind_drop(s, x)
637+
}
638+
)]
602639
Drop {
603640
place: Place,
641+
/// Implementation of `place.ty(): Drop`.
642+
impl_expr: ImplExpr,
604643
target: BasicBlock,
605644
unwind: UnwindAction,
606-
replace: bool,
607645
},
608646
#[custom_arm(
609647
x @ rustc_middle::mir::TerminatorKind::Call { .. } => {

0 commit comments

Comments
 (0)