diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/trans/common.rs index 0689b0ded6ecdcf58f468066d01cc3ae87f6690e..a3ba506fc46a2034b977589d18f3300cb6c89d56 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -214,14 +214,7 @@ fn type_needs_unwind_cleanup_<'tcx>(tcx: &ty::ctxt<'tcx>, } pub fn type_needs_drop<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool { - // Unsized types cannot be dropped automatically - these are lvalues pointing - // to alloca's containing the actual data pointer (and the unsizing info), - // which only be obtained by dereferencing a pointer from which moves are - // not allowed. Datum & friends could possibly be adjusted to avoid getting - // this far - maybe the (*data, info) aggregate could be an SSA value? - // Lvalues don't have to be pointers, just behave like a pointer, but there - // is no telling what other implicit assumptions are lurking around. - ty::type_contents(cx, ty).needs_drop(cx) && type_is_sized(cx, ty) + ty::type_contents(cx, ty).needs_drop(cx) } fn type_is_newtype_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool { diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index ca15da94f073986145383d4869205dc564e21736..9e9ee4537524b81bfc262027c61bb614c45296ad 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -463,11 +463,13 @@ fn unsize_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let ptr_ty = type_of::in_memory_type_of(bcx.ccx(), unsized_ty).ptr_to(); let base = PointerCast(bcx, lval.val, ptr_ty); - let scratch = rvalue_scratch_datum(bcx, unsized_ty, "__fat_ptr"); - Store(bcx, base, get_dataptr(bcx, scratch.val)); - Store(bcx, info, get_len(bcx, scratch.val)); + let llty = type_of::type_of(bcx.ccx(), unsized_ty); + // HACK(eddyb) get around issues with lifetime intrinsics. + let scratch = alloca_no_lifetime(bcx, llty, "__fat_ptr"); + Store(bcx, base, get_dataptr(bcx, scratch)); + Store(bcx, info, get_len(bcx, scratch)); - DatumBlock::new(bcx, scratch.to_expr_datum()) + DatumBlock::new(bcx, Datum::new(scratch, unsized_ty, LvalueExpr)) } fn unsize_unique_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,