about summary refs log tree commit diff
path: root/src/comp/middle
diff options
context:
space:
mode:
authorMichael Sullivan <sully@msully.net>2011-07-26 18:14:36 -0700
committerMichael Sullivan <sully@msully.net>2011-07-27 14:43:35 -0700
commitdb1923159692818becfc0fe386f19cb0f6151855 (patch)
tree9ce01c087965a4f1a7c62b4a07e5fadbec6e55bf /src/comp/middle
parente3f96480968a7c91738414158a61e4f44b402797 (diff)
downloadrust-db1923159692818becfc0fe386f19cb0f6151855.tar.gz
rust-db1923159692818becfc0fe386f19cb0f6151855.zip
Mess around with the casting in trans_bind.
Diffstat (limited to 'src/comp/middle')
-rw-r--r--src/comp/middle/trans.rs21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index cecbe9eb75f..e6e77710092 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -4514,8 +4514,10 @@ fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: &ty::t,
     let lltargetfn =
         bcx.build.GEP(lltarget.val, ~[C_int(0), C_int(abi::fn_field_code)]);
 
-    // Cast the outgoing function to the appropriate type (see the comments in
-    // trans_bind below for why this is necessary).
+    // Cast the outgoing function to the appropriate type.
+    // This is necessary because the type of the function that we have
+    // in the closure does not know how many type descriptors the function
+    // needs to take.
     let lltargetty =
         type_of_fn_from_ty(bcx_ccx(bcx), sp, outgoing_fty, ty_param_count);
     lltargetfn = bcx.build.PointerCast(lltargetfn, T_ptr(T_ptr(lltargetty)));
@@ -4625,21 +4627,12 @@ fn trans_bind_1(cx: &@block_ctxt, f: &@ast::expr, f_res: &lval_result,
     bcx = bindings_tydesc.bcx;
     bcx.build.Store(bindings_tydesc.val, bound_tydesc);
 
-    // Determine the LLVM type for the outgoing function type. This
-    // may be different from the type returned by trans_malloc_boxed()
-    // since we have more information than that function does;
-    // specifically, we know how many type descriptors the outgoing
-    // function has, which type_of() doesn't, as only we know which
-    // item the function refers to.
-    let llfnty = type_of_fn_from_ty(bcx_ccx(bcx), cx.sp,
-                                    outgoing_fty, ty_param_count);
-    let llclosurety = T_ptr(T_fn_pair(*bcx_ccx(bcx), llfnty));
-
     // Store thunk-target.
     let bound_target =
         bcx.build.GEP(closure, ~[C_int(0), C_int(abi::closure_elt_target)]);
-    let src = bcx.build.Load(f_res.res.val);
-    bound_target = bcx.build.PointerCast(bound_target, llclosurety);
+    let llclosurety = T_ptr(type_of(bcx_ccx(cx), cx.sp, outgoing_fty));
+    let src_loc = bcx.build.PointerCast(f_res.res.val, llclosurety);
+    let src = bcx.build.Load(src_loc);
     bcx.build.Store(src, bound_target);
 
     // Copy expr values into boxed bindings.