Skip to content

Commit d94fe1d

Browse files
committed
Fix calling drop_in_place_real with empty drop glue
fixes rust-lang#209
1 parent 43a68c3 commit d94fe1d

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/abi.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,26 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>(
484484
.map(|&(ref place, bb)| (trans_place(fx, place), bb));
485485

486486
if let ty::FnDef(def_id, substs) = fn_ty.sty {
487-
let sig = ty_fn_sig(fx.tcx, fn_ty);
488-
489-
if sig.abi == Abi::RustIntrinsic {
490-
crate::intrinsics::codegen_intrinsic_call(fx, def_id, substs, args, destination);
491-
return;
487+
let instance = ty::Instance::resolve(
488+
fx.tcx,
489+
ty::ParamEnv::reveal_all(),
490+
def_id,
491+
substs,
492+
).unwrap();
493+
494+
match instance.def {
495+
InstanceDef::Intrinsic(_) => {
496+
crate::intrinsics::codegen_intrinsic_call(fx, def_id, substs, args, destination);
497+
return;
498+
}
499+
InstanceDef::DropGlue(_, None) => {
500+
// empty drop glue - a nop.
501+
let (_, dest) = destination.expect("Non terminating drop_in_place_real???");
502+
let ret_ebb = fx.get_ebb(dest);
503+
fx.bcx.ins().jump(ret_ebb, &[]);
504+
return;
505+
}
506+
_ => {}
492507
}
493508
}
494509

0 commit comments

Comments
 (0)