@@ -15,7 +15,13 @@ import trans::{
15
15
new_sub_block_ctxt
16
16
} ;
17
17
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
+ }
19
25
20
26
fn trans_uniq ( cx : @block_ctxt , contents : @ast:: expr ,
21
27
node_id : ast:: node_id ) -> result {
@@ -25,17 +31,18 @@ fn trans_uniq(cx: @block_ctxt, contents: @ast::expr,
25
31
bcx = lv. bcx ;
26
32
27
33
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) ;
29
36
let { bcx, val: llptr } = alloc_uniq ( bcx, uniq_ty) ;
30
37
31
38
bcx = move_val_if_temp ( bcx, INIT , llptr, lv,
32
- content_ty ( bcx , uniq_ty ) ) ;
39
+ content_ty) ;
33
40
34
41
ret rslt( bcx, llptr) ;
35
42
}
36
43
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 {
39
46
40
47
let bcx = cx;
41
48
let contents_ty = content_ty ( bcx, uniq_ty) ;
@@ -54,26 +61,27 @@ fn alloc_uniq(cx: @block_ctxt, uniq_ty: ty::t) -> result {
54
61
ret rslt( bcx, llptr) ;
55
62
}
56
63
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 {
59
66
67
+ let bcx = cx;
60
68
let free_cx = new_sub_block_ctxt ( bcx, "uniq_free" ) ;
61
69
let next_cx = new_sub_block_ctxt ( bcx, "uniq_free_next" ) ;
62
70
let vptr = Load ( bcx, v) ;
63
71
let null_test = IsNull ( bcx, vptr) ;
64
72
CondBr ( bcx, null_test, next_cx. llbb , free_cx. llbb ) ;
65
73
66
74
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) ) ;
68
76
let bcx = trans_shared_free ( bcx, vptr) ;
69
77
Store ( bcx, C_null ( val_ty ( vptr) ) , v) ;
70
78
Br ( bcx, next_cx. llbb ) ;
71
79
72
80
next_cx
73
81
}
74
82
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 {
77
85
78
86
alt ty:: struct ( bcx_tcx ( bcx) , t) {
79
87
ty:: ty_uniq ( { ty: ct, _} ) { ct }
0 commit comments