@@ -1691,29 +1691,20 @@ fn trans_uniq_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
1691
1691
immediate_rvalue_bcx ( bcx, val, box_ty) . to_expr_datumblock ( )
1692
1692
}
1693
1693
1694
- fn ref_fat_ptr < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
1695
- lval : Datum < ' tcx , Lvalue > )
1696
- -> DatumBlock < ' blk , ' tcx , Expr > {
1697
- let dest_ty = bcx. tcx ( ) . mk_imm_ref ( bcx. tcx ( ) . mk_region ( ty:: ReStatic ) , lval. ty ) ;
1698
- let scratch = rvalue_scratch_datum ( bcx, dest_ty, "__fat_ptr" ) ;
1699
- memcpy_ty ( bcx, scratch. val , lval. val , scratch. ty ) ;
1700
-
1701
- DatumBlock :: new ( bcx, scratch. to_expr_datum ( ) )
1702
- }
1703
-
1704
1694
fn trans_addr_of < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
1705
1695
expr : & hir:: Expr ,
1706
1696
subexpr : & hir:: Expr )
1707
1697
-> DatumBlock < ' blk , ' tcx , Expr > {
1708
1698
let _icx = push_ctxt ( "trans_addr_of" ) ;
1709
1699
let mut bcx = bcx;
1710
1700
let sub_datum = unpack_datum ! ( bcx, trans_to_lvalue( bcx, subexpr, "addr_of" ) ) ;
1701
+ let ty = expr_ty ( bcx, expr) ;
1711
1702
if !type_is_sized ( bcx. tcx ( ) , sub_datum. ty ) {
1712
- // DST lvalue, close to a fat pointer
1713
- ref_fat_ptr ( bcx, sub_datum)
1703
+ // Always generate an lvalue datum, because this pointer doesn't own
1704
+ // the data and cleanup is scheduled elsewhere.
1705
+ DatumBlock :: new ( bcx, Datum :: new ( sub_datum. val , ty, LvalueExpr ( sub_datum. kind ) ) )
1714
1706
} else {
1715
1707
// Sized value, ref to a thin pointer
1716
- let ty = expr_ty ( bcx, expr) ;
1717
1708
immediate_rvalue_bcx ( bcx, sub_datum. val , ty) . to_expr_datumblock ( )
1718
1709
}
1719
1710
}
0 commit comments