@@ -2053,7 +2053,7 @@ fn move_val(cx: @block_ctxt, action: copy_action, dst: ValueRef,
2053
2053
ret cx;
2054
2054
} else if ty:: type_is_nil ( tcx, t) || ty:: type_is_bot ( tcx, t) {
2055
2055
ret cx;
2056
- } else if ty:: type_is_boxed ( tcx, t) {
2056
+ } else if ty:: type_is_boxed ( tcx, t) || ty :: type_is_unique_box ( tcx , t ) {
2057
2057
if src. is_mem { src_val = Load ( cx, src_val) ; }
2058
2058
if action == DROP_EXISTING { cx = drop_ty ( cx, dst, t) ; }
2059
2059
Store ( cx, src_val, dst) ;
@@ -3138,7 +3138,6 @@ fn trans_lval(cx: @block_ctxt, e: @ast::expr) -> lval_result {
3138
3138
InBoundsGEP ( sub. bcx , sub. val ,
3139
3139
[ C_int ( 0 ) , C_int ( abi:: box_rc_field_body) ] )
3140
3140
}
3141
- ty:: ty_uniq ( _) { fail "uniq lval translation unimplemented" }
3142
3141
ty:: ty_res ( _, _, _) {
3143
3142
InBoundsGEP ( sub. bcx , sub. val , [ C_int ( 0 ) , C_int ( 1 ) ] )
3144
3143
}
@@ -3151,7 +3150,7 @@ fn trans_lval(cx: @block_ctxt, e: @ast::expr) -> lval_result {
3151
3150
} else { T_typaram_ptr ( ccx. tn ) } ;
3152
3151
PointerCast ( sub. bcx , sub. val , ellty)
3153
3152
}
3154
- ty:: ty_ptr ( _) { sub. val }
3153
+ ty:: ty_ptr ( _) | ty :: ty_uniq ( _ ) { sub. val }
3155
3154
} ;
3156
3155
ret lval_mem( sub. bcx , val) ;
3157
3156
}
@@ -4306,7 +4305,7 @@ fn with_out_method(work: fn(out_method) -> result, cx: @block_ctxt,
4306
4305
// immediate-ness of the type.
4307
4306
fn type_is_immediate ( ccx : @crate_ctxt , t : ty:: t ) -> bool {
4308
4307
ret ty:: type_is_scalar ( ccx. tcx , t) || ty:: type_is_boxed ( ccx. tcx , t) ||
4309
- ty:: type_is_native ( ccx. tcx , t) ;
4308
+ ty :: type_is_unique_box ( ccx . tcx , t ) || ty:: type_is_native ( ccx. tcx , t) ;
4310
4309
}
4311
4310
4312
4311
fn do_spill ( cx : @block_ctxt , v : ValueRef , t : ty:: t ) -> result {
@@ -4502,6 +4501,9 @@ fn trans_uniq(cx: @block_ctxt, contents: @ast::expr,
4502
4501
node_id : ast:: node_id ) -> result {
4503
4502
let bcx = cx;
4504
4503
4504
+ let lv = trans_lval ( bcx, contents) ;
4505
+ bcx = lv. bcx ;
4506
+
4505
4507
let contents_ty = ty:: expr_ty ( bcx_tcx ( bcx) , contents) ;
4506
4508
let r = size_of ( bcx, contents_ty) ;
4507
4509
bcx = r. bcx ;
@@ -4513,15 +4515,11 @@ fn trans_uniq(cx: @block_ctxt, contents: @ast::expr,
4513
4515
bcx = r. bcx ;
4514
4516
let llptr = r. val ;
4515
4517
4516
- let uniq_ty = node_id_type ( bcx_ccx ( cx) , node_id) ;
4517
- r = alloc_ty ( bcx, uniq_ty) ;
4518
- let llptrptr = r. val ;
4519
- bcx = r. bcx ;
4520
- Store ( bcx, llptr, llptrptr) ;
4518
+ bcx = move_val_if_temp ( bcx, INIT , llptr, lv, contents_ty) ;
4521
4519
4522
- r = trans_expr_out ( bcx , contents , save_in ( llptr ) ) ;
4523
- add_clean_temp ( r. bcx , llptrptr , uniq_ty) ;
4524
- ret rslt( r. bcx , llptrptr ) ;
4520
+ let uniq_ty = node_id_type ( bcx_ccx ( cx ) , node_id ) ;
4521
+ add_clean_temp ( r. bcx , llptr , uniq_ty) ;
4522
+ ret rslt( r. bcx , llptr ) ;
4525
4523
}
4526
4524
4527
4525
fn trans_break_cont ( sp : span , cx : @block_ctxt , to_end : bool ) -> result {
0 commit comments