@@ -1691,29 +1691,20 @@ fn trans_uniq_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
16911691 immediate_rvalue_bcx ( bcx, val, box_ty) . to_expr_datumblock ( )
16921692}
16931693
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-
17041694fn trans_addr_of < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
17051695 expr : & hir:: Expr ,
17061696 subexpr : & hir:: Expr )
17071697 -> DatumBlock < ' blk , ' tcx , Expr > {
17081698 let _icx = push_ctxt ( "trans_addr_of" ) ;
17091699 let mut bcx = bcx;
17101700 let sub_datum = unpack_datum ! ( bcx, trans_to_lvalue( bcx, subexpr, "addr_of" ) ) ;
1701+ let ty = expr_ty ( bcx, expr) ;
17111702 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 ) ) )
17141706 } else {
17151707 // Sized value, ref to a thin pointer
1716- let ty = expr_ty ( bcx, expr) ;
17171708 immediate_rvalue_bcx ( bcx, sub_datum. val , ty) . to_expr_datumblock ( )
17181709 }
17191710}
0 commit comments