@@ -1700,29 +1700,20 @@ fn trans_uniq_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
17001700 immediate_rvalue_bcx ( bcx, val, box_ty) . to_expr_datumblock ( )
17011701}
17021702
1703- fn ref_fat_ptr < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
1704- lval : Datum < ' tcx , Lvalue > )
1705- -> DatumBlock < ' blk , ' tcx , Expr > {
1706- let dest_ty = bcx. tcx ( ) . mk_imm_ref ( bcx. tcx ( ) . mk_region ( ty:: ReStatic ) , lval. ty ) ;
1707- let scratch = rvalue_scratch_datum ( bcx, dest_ty, "__fat_ptr" ) ;
1708- memcpy_ty ( bcx, scratch. val , lval. val , scratch. ty ) ;
1709-
1710- DatumBlock :: new ( bcx, scratch. to_expr_datum ( ) )
1711- }
1712-
17131703fn trans_addr_of < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
17141704 expr : & hir:: Expr ,
17151705 subexpr : & hir:: Expr )
17161706 -> DatumBlock < ' blk , ' tcx , Expr > {
17171707 let _icx = push_ctxt ( "trans_addr_of" ) ;
17181708 let mut bcx = bcx;
17191709 let sub_datum = unpack_datum ! ( bcx, trans_to_lvalue( bcx, subexpr, "addr_of" ) ) ;
1710+ let ty = expr_ty ( bcx, expr) ;
17201711 if !type_is_sized ( bcx. tcx ( ) , sub_datum. ty ) {
1721- // DST lvalue, close to a fat pointer
1722- ref_fat_ptr ( bcx, sub_datum)
1712+ // Always generate an lvalue datum, because this pointer doesn't own
1713+ // the data and cleanup is scheduled elsewhere.
1714+ DatumBlock :: new ( bcx, Datum :: new ( sub_datum. val , ty, LvalueExpr ( sub_datum. kind ) ) )
17231715 } else {
17241716 // Sized value, ref to a thin pointer
1725- let ty = expr_ty ( bcx, expr) ;
17261717 immediate_rvalue_bcx ( bcx, sub_datum. val , ty) . to_expr_datumblock ( )
17271718 }
17281719}
0 commit comments