sized_args = [v0];
&sized_args
} else {
+ // FIXME(#36457) -- we should pass unsized values to drop glue as two arguments
unsized_args = [
Load(bcx, get_dataptr(bcx, v0)),
Load(bcx, get_meta(bcx, v0))
}
}
-fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, g: DropGlueKind<'tcx>)
+fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+ v0: ValueRef,
+ g: DropGlueKind<'tcx>)
-> Block<'blk, 'tcx> {
let t = g.ty();
let llval = get_dataptr(bcx, v0);
let llbox = Load(bcx, llval);
let bcx = drop_ty(bcx, v0, content_ty, DebugLoc::None);
+ // FIXME(#36457) -- we should pass unsized values to drop glue as two arguments
let info = get_meta(bcx, v0);
let info = Load(bcx, info);
let (llsize, llalign) =
// No support in vtable for distinguishing destroying with
// versus without calling Drop::drop. Assert caller is
// okay with always calling the Drop impl, if any.
+ // FIXME(#36457) -- we should pass unsized values to drop glue as two arguments
assert!(!skip_dtor);
let data_ptr = get_dataptr(bcx, v0);
let vtable_ptr = Load(bcx, get_meta(bcx, v0));
let value = if type_is_sized(cx.tcx(), t) {
adt::MaybeSizedValue::sized(av)
} else {
+ // FIXME(#36457) -- we should pass unsized values as two arguments
let data = Load(cx, get_dataptr(cx, av));
let info = Load(cx, get_meta(cx, av));
adt::MaybeSizedValue::unsized_(data, info)
let val = if type_is_sized(cx.tcx(), field_ty) {
llfld_a
} else {
+ // FIXME(#36457) -- we should pass unsized values as two arguments
let scratch = alloc_ty(cx, field_ty, "__fat_ptr_iter");
Store(cx, llfld_a, get_dataptr(cx, scratch));
Store(cx, value.meta, get_meta(cx, scratch));
let lvalue = self.trans_lvalue(&bcx, location);
let drop_fn = glue::get_drop_glue(bcx.ccx(), ty);
let drop_ty = glue::get_drop_glue_type(bcx.tcx(), ty);
- let llvalue = if drop_ty != ty {
- bcx.pointercast(lvalue.llval, type_of::type_of(bcx.ccx(), drop_ty).ptr_to())
+ let is_sized = common::type_is_sized(bcx.tcx(), ty);
+ let llvalue = if is_sized {
+ if drop_ty != ty {
+ bcx.pointercast(lvalue.llval, type_of::type_of(bcx.ccx(), drop_ty).ptr_to())
+ } else {
+ lvalue.llval
+ }
} else {
- lvalue.llval
+ // FIXME(#36457) Currently drop glue takes sized
+ // values as a `*(data, meta)`, but elsewhere in
+ // MIR we pass `(data, meta)` as two separate
+ // arguments. It would be better to fix drop glue,
+ // but I am shooting for a quick fix to #35546
+ // here that can be cleanly backported to beta, so
+ // I want to avoid touching all of trans.
+ bcx.with_block(|bcx| {
+ let scratch = base::alloc_ty(bcx, ty, "drop");
+ base::call_lifetime_start(bcx, scratch);
+ build::Store(bcx, lvalue.llval, base::get_dataptr(bcx, scratch));
+ build::Store(bcx, lvalue.llextra, base::get_meta(bcx, scratch));
+ scratch
+ })
};
if let Some(unwind) = unwind {
bcx.invoke(drop_fn,