diff options
Diffstat (limited to 'src/librustc_trans/glue.rs')
| -rw-r--r-- | src/librustc_trans/glue.rs | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/librustc_trans/glue.rs b/src/librustc_trans/glue.rs index b24f00ee697..65f3c7add4d 100644 --- a/src/librustc_trans/glue.rs +++ b/src/librustc_trans/glue.rs @@ -79,16 +79,21 @@ pub fn get_drop_glue_type<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>, t: Ty<'t return scx.tcx().types.i8; } match t.sty { - ty::TyBox(typ) if !scx.type_needs_drop(typ) && scx.type_is_sized(typ) => { - scx.tcx().infer_ctxt((), traits::Reveal::All).enter(|infcx| { - let layout = t.layout(&infcx).unwrap(); - if layout.size(&scx.tcx().data_layout).bytes() == 0 { - // `Box<ZeroSizeType>` does not allocate. - scx.tcx().types.i8 - } else { - t - } - }) + ty::TyAdt(def, _) if def.is_box() => { + let typ = t.boxed_ty(); + if !scx.type_needs_drop(typ) && scx.type_is_sized(typ) { + scx.tcx().infer_ctxt((), traits::Reveal::All).enter(|infcx| { + let layout = t.layout(&infcx).unwrap(); + if layout.size(&scx.tcx().data_layout).bytes() == 0 { + // `Box<ZeroSizeType>` does not allocate. + scx.tcx().types.i8 + } else { + t + } + }) + } else { + t + } } _ => t } @@ -205,11 +210,12 @@ pub fn implement_drop_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, g: DropGlueKi }; let bcx = match t.sty { - ty::TyBox(content_ty) => { - // Support for TyBox is built-in and its drop glue is + ty::TyAdt(def, _) if def.is_box() => { + // Support for Box is built-in and its drop glue is // special. It may move to library and have Drop impl. As - // a safe-guard, assert TyBox not used with TyContents. + // a safe-guard, assert Box not used with TyContents. assert!(!skip_dtor); + let content_ty = t.boxed_ty(); let ptr = if !bcx.ccx.shared().type_is_sized(content_ty) { let llbox = bcx.load(get_dataptr(&bcx, ptr.llval)); let info = bcx.load(get_meta(&bcx, ptr.llval)); |
