@@ -1933,6 +1933,9 @@ fn make_copy_glue(&@block_ctxt cx, ValueRef v, &ty::t t) {
1933
1933
bcx = incr_refcnt_of_boxed( cx, cx. build. Load ( v) ) . bcx;
1934
1934
} else if ( ty:: type_is_structural( cx. fcx. lcx. ccx. tcx, t) ) {
1935
1935
bcx = iter_structural_ty( cx, v, t, bind copy_ty( _, _, _) ) . bcx;
1936
+ if ( ty:: type_owns_heap_mem( cx. fcx. lcx. ccx. tcx, t) ) {
1937
+ bcx = duplicate_heap_parts( bcx, v, t) . bcx;
1938
+ }
1936
1939
} else { bcx = cx; }
1937
1940
bcx. build. RetVoid ( ) ;
1938
1941
}
@@ -3054,7 +3057,8 @@ fn compare(&@block_ctxt cx, ValueRef lhs, ValueRef rhs, &ty::t t,
3054
3057
}
3055
3058
3056
3059
fn copy_ty( & @block_ctxt cx, ValueRef v, ty:: t t) -> result {
3057
- if ( ty:: type_has_pointers( cx. fcx. lcx. ccx. tcx, t) ) {
3060
+ if ( ty:: type_has_pointers( cx. fcx. lcx. ccx. tcx, t) ||
3061
+ ty:: type_owns_heap_mem( cx. fcx. lcx. ccx. tcx, t) ) {
3058
3062
ret call_tydesc_glue( cx, v, t, abi:: tydesc_field_copy_glue) ;
3059
3063
}
3060
3064
ret rslt( cx, C_nil ( ) ) ;
@@ -3168,20 +3172,24 @@ fn copy_val(&@block_ctxt cx, copy_action action, ValueRef dst, ValueRef src,
3168
3172
ty:: type_is_bot( ccx. tcx, t) ) {
3169
3173
ret rslt( cx, C_nil ( ) ) ;
3170
3174
} else if ( ty:: type_is_boxed( ccx. tcx, t) ) {
3171
- auto r = copy_ty ( cx , src , t ) ;
3175
+ auto bcx ;
3172
3176
if ( action == DROP_EXISTING ) {
3173
- r = drop_ty( r. bcx, r. bcx. build. Load ( dst) , t) ;
3177
+ bcx = drop_ty( cx, cx. build. Load ( dst) , t) . bcx;
3178
+ } else {
3179
+ bcx = cx;
3174
3180
}
3175
- ret rslt( r. bcx, r. bcx. build. Store ( src, dst) ) ;
3181
+ bcx = copy_ty( bcx, src, t) . bcx;
3182
+ ret rslt( bcx, bcx. build. Store ( src, dst) ) ;
3176
3183
} else if ( ty:: type_is_structural( ccx. tcx, t) ||
3177
3184
ty:: type_has_dynamic_size( ccx. tcx, t) ) {
3178
- auto r = copy_ty ( cx , src , t ) ;
3179
- if ( action == DROP_EXISTING ) { r = drop_ty ( r . bcx , dst , t ) ; }
3180
- r = memmove_ty ( r . bcx , dst, src , t ) ;
3181
- if ( ty :: type_owns_heap_mem ( ccx . tcx , t ) ) {
3182
- r = duplicate_heap_parts ( cx , dst , t ) ;
3185
+ auto bcx ;
3186
+ if ( action == DROP_EXISTING ) {
3187
+ bcx = drop_ty ( cx , dst, t ) . bcx ;
3188
+ } else {
3189
+ bcx = cx ;
3183
3190
}
3184
- ret r;
3191
+ bcx = memmove_ty( bcx, dst, src, t) . bcx;
3192
+ ret copy_ty( bcx, dst, t) ;
3185
3193
}
3186
3194
ccx. sess. bug( "unexpected type in trans:: copy_val: " +
3187
3195
ty_to_str( ccx. tcx, t) ) ;
0 commit comments