@@ -15,7 +15,13 @@ import trans::{
1515 new_sub_block_ctxt
1616} ;
1717
18- export trans_uniq, make_free_glue;
18+ export trans_uniq, make_free_glue, type_is_unique_box;
19+
20+ pure fn type_is_unique_box ( bcx : @block_ctxt , ty : ty:: t ) -> bool {
21+ unchecked {
22+ ty : : type_is_unique_box ( bcx_tcx ( bcx) , ty)
23+ }
24+ }
1925
2026fn trans_uniq ( cx : @block_ctxt , contents : @ast:: expr ,
2127 node_id : ast:: node_id ) -> result {
@@ -25,17 +31,18 @@ fn trans_uniq(cx: @block_ctxt, contents: @ast::expr,
2531 bcx = lv. bcx ;
2632
2733 let uniq_ty = node_id_type ( bcx_ccx ( cx) , node_id) ;
28- assert ty:: type_is_unique_box ( bcx_tcx ( cx) , uniq_ty) ;
34+ check type_is_unique_box ( bcx, uniq_ty) ;
35+ let content_ty = content_ty ( bcx, uniq_ty) ;
2936 let { bcx, val: llptr } = alloc_uniq ( bcx, uniq_ty) ;
3037
3138 bcx = move_val_if_temp ( bcx, INIT , llptr, lv,
32- content_ty ( bcx , uniq_ty ) ) ;
39+ content_ty) ;
3340
3441 ret rslt( bcx, llptr) ;
3542}
3643
37- fn alloc_uniq ( cx : @block_ctxt , uniq_ty : ty:: t ) -> result {
38- assert ty :: type_is_unique_box ( bcx_tcx ( cx ) , uniq_ty) ;
44+ fn alloc_uniq( cx : @block_ctxt , uniq_ty : ty:: t )
45+ : type_is_unique_box ( cx , uniq_ty ) -> result {
3946
4047 let bcx = cx;
4148 let contents_ty = content_ty ( bcx, uniq_ty) ;
@@ -54,26 +61,27 @@ fn alloc_uniq(cx: @block_ctxt, uniq_ty: ty::t) -> result {
5461 ret rslt( bcx, llptr) ;
5562}
5663
57- fn make_free_glue ( bcx : @block_ctxt , v : ValueRef , t : ty:: t ) -> @ block_ctxt {
58- assert ty :: type_is_unique_box ( bcx_tcx ( bcx ) , t) ;
64+ fn make_free_glue( cx : @block_ctxt , v : ValueRef , t : ty:: t )
65+ : type_is_unique_box ( cx , t ) -> @ block_ctxt {
5966
67+ let bcx = cx;
6068 let free_cx = new_sub_block_ctxt ( bcx, "uniq_free" ) ;
6169 let next_cx = new_sub_block_ctxt ( bcx, "uniq_free_next" ) ;
6270 let vptr = Load ( bcx, v) ;
6371 let null_test = IsNull ( bcx, vptr) ;
6472 CondBr ( bcx, null_test, next_cx. llbb , free_cx. llbb ) ;
6573
6674 let bcx = free_cx;
67- let bcx = drop_ty ( bcx, vptr, content_ty ( bcx , t) ) ;
75+ let bcx = drop_ty ( bcx, vptr, content_ty ( cx , t) ) ;
6876 let bcx = trans_shared_free ( bcx, vptr) ;
6977 Store ( bcx, C_null ( val_ty ( vptr) ) , v) ;
7078 Br ( bcx, next_cx. llbb ) ;
7179
7280 next_cx
7381}
7482
75- fn content_ty ( bcx : @block_ctxt , t : ty:: t ) -> ty :: t {
76- assert ty :: type_is_unique_box ( bcx_tcx ( bcx) , t) ;
83+ fn content_ty( bcx : @block_ctxt , t : ty:: t )
84+ : type_is_unique_box ( bcx , t ) -> ty :: t {
7785
7886 alt ty:: struct ( bcx_tcx ( bcx) , t) {
7987 ty:: ty_uniq ( { ty: ct, _} ) { ct }
0 commit comments