@@ -2041,7 +2041,7 @@ fn copy_val_no_check(cx: @block_ctxt, action: copy_action, dst: ValueRef,
2041
2041
ret take_ty( bcx, dst, t) ;
2042
2042
}
2043
2043
if type_is_structural_or_param ( ccx. tcx , t) || ty:: type_is_vec ( ccx. tcx , t)
2044
- {
2044
+ {
2045
2045
let bcx = cx;
2046
2046
if action == DROP_EXISTING { bcx = drop_ty ( cx, dst, t) ; }
2047
2047
bcx = memmove_ty ( bcx, dst, src, t) . bcx ;
@@ -4518,7 +4518,24 @@ fn trans_uniq(cx: @block_ctxt, contents: @ast::expr,
4518
4518
let lv = trans_lval ( bcx, contents) ;
4519
4519
bcx = lv. bcx ;
4520
4520
4521
- let contents_ty = ty:: expr_ty ( bcx_tcx ( bcx) , contents) ;
4521
+ let uniq_ty = node_id_type ( bcx_ccx ( cx) , node_id) ;
4522
+ let { bcx, val: llptr } = alloc_uniq ( bcx, uniq_ty) ;
4523
+
4524
+ bcx = move_val_if_temp ( bcx, INIT , llptr, lv,
4525
+ ty_uniq_contents ( bcx, uniq_ty) ) ;
4526
+
4527
+ ret rslt( bcx, llptr) ;
4528
+ }
4529
+
4530
+ fn ty_uniq_contents ( cx : @block_ctxt , uniq_ty : ty:: t ) -> ty:: t {
4531
+ alt ty:: struct ( bcx_tcx ( cx) , uniq_ty) {
4532
+ ty:: ty_uniq ( { ty: ct, _} ) { ct }
4533
+ }
4534
+ }
4535
+
4536
+ fn alloc_uniq ( cx : @block_ctxt , uniq_ty : ty:: t ) -> result {
4537
+ let bcx = cx;
4538
+ let contents_ty = ty_uniq_contents ( cx, uniq_ty) ;
4522
4539
let r = size_of ( bcx, contents_ty) ;
4523
4540
bcx = r. bcx ;
4524
4541
let llsz = r. val ;
@@ -4529,11 +4546,9 @@ fn trans_uniq(cx: @block_ctxt, contents: @ast::expr,
4529
4546
bcx = r. bcx ;
4530
4547
let llptr = r. val ;
4531
4548
4532
- bcx = move_val_if_temp ( bcx, INIT , llptr, lv , contents_ty ) ;
4549
+ add_clean_temp ( bcx, llptr, uniq_ty ) ;
4533
4550
4534
- let uniq_ty = node_id_type ( bcx_ccx ( cx) , node_id) ;
4535
- add_clean_temp ( r. bcx , llptr, uniq_ty) ;
4536
- ret rslt( r. bcx , llptr) ;
4551
+ ret rslt( bcx, llptr) ;
4537
4552
}
4538
4553
4539
4554
fn trans_break_cont ( sp : span , cx : @block_ctxt , to_end : bool ) -> result {
0 commit comments