about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-09-22 12:07:38 -0700
committerBrian Anderson <banderson@mozilla.com>2011-09-22 13:53:33 -0700
commitc4f02a7925df2dcd8575f1e4d9dc66f76f9d0495 (patch)
tree41caf27eb36e7fcfe5c62fc7a580259610dbf9fe /src/comp
parent8492eed137ab9435d76c7ff2bdad491dff5756e2 (diff)
downloadrust-c4f02a7925df2dcd8575f1e4d9dc66f76f9d0495.tar.gz
rust-c4f02a7925df2dcd8575f1e4d9dc66f76f9d0495.zip
Sprinkle some asserts through trans_uniq
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/trans.rs7
-rw-r--r--src/comp/middle/trans_uniq.rs7
2 files changed, 14 insertions, 0 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 583e29786e9..ca85f94b4ae 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -2028,6 +2028,13 @@ fn copy_val_no_check(cx: @block_ctxt, action: copy_action, dst: ValueRef,
         Store(bcx, src, dst);
         ret take_ty(bcx, dst, t);
     }
+    if ty::type_is_unique_box(ccx.tcx, t) {
+        let bcx = cx;
+        // FIXME (409): Write a test and uncomment
+        //if action == DROP_EXISTING { bcx = drop_ty(cx, dst, t); }
+        //ret trans_uniq::copy_val(bcx, dst, src, t);
+        fail;
+    }
     if type_is_structural_or_param(ccx.tcx, t) || ty::type_is_vec(ccx.tcx, t)
         {
         let bcx = cx;
diff --git a/src/comp/middle/trans_uniq.rs b/src/comp/middle/trans_uniq.rs
index fecf42fc702..851aec85300 100644
--- a/src/comp/middle/trans_uniq.rs
+++ b/src/comp/middle/trans_uniq.rs
@@ -25,6 +25,7 @@ fn trans_uniq(cx: @block_ctxt, contents: @ast::expr,
     bcx = lv.bcx;
 
     let uniq_ty = node_id_type(bcx_ccx(cx), node_id);
+    assert ty::type_is_unique_box(bcx_tcx(cx), uniq_ty);
     let {bcx, val: llptr} = alloc_uniq(bcx, uniq_ty);
 
     bcx = move_val_if_temp(bcx, INIT, llptr, lv,
@@ -34,6 +35,8 @@ fn trans_uniq(cx: @block_ctxt, contents: @ast::expr,
 }
 
 fn alloc_uniq(cx: @block_ctxt, uniq_ty: ty::t) -> result {
+    assert ty::type_is_unique_box(bcx_tcx(cx), uniq_ty);
+
     let bcx = cx;
     let contents_ty = content_ty(bcx, uniq_ty);
     let r = size_of(bcx, contents_ty);
@@ -52,6 +55,8 @@ fn alloc_uniq(cx: @block_ctxt, uniq_ty: ty::t) -> result {
 }
 
 fn make_free_glue(bcx: @block_ctxt, v: ValueRef, t: ty::t) -> @block_ctxt {
+    assert ty::type_is_unique_box(bcx_tcx(bcx), t);
+
     let free_cx = new_sub_block_ctxt(bcx, "uniq_free");
     let next_cx = new_sub_block_ctxt(bcx, "uniq_free_next");
     let vptr = Load(bcx, v);
@@ -68,6 +73,8 @@ fn make_free_glue(bcx: @block_ctxt, v: ValueRef, t: ty::t) -> @block_ctxt {
 }
 
 fn content_ty(bcx: @block_ctxt, t: ty::t) -> ty::t {
+    assert ty::type_is_unique_box(bcx_tcx(bcx), t);
+
     alt ty::struct(bcx_tcx(bcx), t) {
       ty::ty_uniq({ty: ct, _}) { ct }
     }