Skip to content

Commit c4f02a7

Browse files
committed
Sprinkle some asserts through trans_uniq
1 parent 8492eed commit c4f02a7

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/comp/middle/trans.rs

+7
Original file line numberDiff line numberDiff line change
@@ -2028,6 +2028,13 @@ fn copy_val_no_check(cx: @block_ctxt, action: copy_action, dst: ValueRef,
20282028
Store(bcx, src, dst);
20292029
ret take_ty(bcx, dst, t);
20302030
}
2031+
if ty::type_is_unique_box(ccx.tcx, t) {
2032+
let bcx = cx;
2033+
// FIXME (409): Write a test and uncomment
2034+
//if action == DROP_EXISTING { bcx = drop_ty(cx, dst, t); }
2035+
//ret trans_uniq::copy_val(bcx, dst, src, t);
2036+
fail;
2037+
}
20312038
if type_is_structural_or_param(ccx.tcx, t) || ty::type_is_vec(ccx.tcx, t)
20322039
{
20332040
let bcx = cx;

src/comp/middle/trans_uniq.rs

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ fn trans_uniq(cx: @block_ctxt, contents: @ast::expr,
2525
bcx = lv.bcx;
2626

2727
let uniq_ty = node_id_type(bcx_ccx(cx), node_id);
28+
assert ty::type_is_unique_box(bcx_tcx(cx), uniq_ty);
2829
let {bcx, val: llptr} = alloc_uniq(bcx, uniq_ty);
2930

3031
bcx = move_val_if_temp(bcx, INIT, llptr, lv,
@@ -34,6 +35,8 @@ fn trans_uniq(cx: @block_ctxt, contents: @ast::expr,
3435
}
3536

3637
fn alloc_uniq(cx: @block_ctxt, uniq_ty: ty::t) -> result {
38+
assert ty::type_is_unique_box(bcx_tcx(cx), uniq_ty);
39+
3740
let bcx = cx;
3841
let contents_ty = content_ty(bcx, uniq_ty);
3942
let r = size_of(bcx, contents_ty);
@@ -52,6 +55,8 @@ fn alloc_uniq(cx: @block_ctxt, uniq_ty: ty::t) -> result {
5255
}
5356

5457
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);
59+
5560
let free_cx = new_sub_block_ctxt(bcx, "uniq_free");
5661
let next_cx = new_sub_block_ctxt(bcx, "uniq_free_next");
5762
let vptr = Load(bcx, v);
@@ -68,6 +73,8 @@ fn make_free_glue(bcx: @block_ctxt, v: ValueRef, t: ty::t) -> @block_ctxt {
6873
}
6974

7075
fn content_ty(bcx: @block_ctxt, t: ty::t) -> ty::t {
76+
assert ty::type_is_unique_box(bcx_tcx(bcx), t);
77+
7178
alt ty::struct(bcx_tcx(bcx), t) {
7279
ty::ty_uniq({ty: ct, _}) { ct }
7380
}

0 commit comments

Comments
 (0)