@@ -3364,7 +3364,7 @@ fn trans_bind_thunk(@crate_ctxt cx,
3364
3364
lltargetclosure = bcx. build. Load ( lltargetclosure) ;
3365
3365
3366
3366
auto outgoing_ret_ty = ty. ty_fn_ret( outgoing_fty) ;
3367
- auto outgoing_arg_tys = ty. ty_fn_args( outgoing_fty) ;
3367
+ auto outgoing_args = ty. ty_fn_args( outgoing_fty) ;
3368
3368
3369
3369
auto llretptr = fcx. llretptr;
3370
3370
if ( ty. type_has_dynamic_size( outgoing_ret_ty) ) {
@@ -3392,7 +3392,14 @@ fn trans_bind_thunk(@crate_ctxt cx,
3392
3392
let uint a = 2 u + i; // retptr, task ptr, env come first
3393
3393
let int b = 0 ;
3394
3394
let uint outgoing_arg_index = 0 u;
3395
+ let vec[ TypeRef ] llout_arg_tys =
3396
+ type_of_explicit_args ( cx, outgoing_args) ;
3397
+
3395
3398
for ( option. t[ @ast. expr] arg in args) {
3399
+
3400
+ auto out_arg = outgoing_args. ( outgoing_arg_index) ;
3401
+ auto llout_arg_ty = llout_arg_tys. ( outgoing_arg_index) ;
3402
+
3396
3403
alt ( arg) {
3397
3404
3398
3405
// Arg provided at binding time; thunk copies it from closure.
@@ -3403,22 +3410,31 @@ fn trans_bind_thunk(@crate_ctxt cx,
3403
3410
abi. box_rc_field_body,
3404
3411
abi. closure_elt_bindings,
3405
3412
b) ) ;
3406
- // FIXME: possibly support passing aliases someday.
3413
+
3407
3414
bcx = bound_arg. bcx;
3408
- llargs += bcx. build. Load ( bound_arg. val) ;
3415
+ auto val = bound_arg. val;
3416
+
3417
+ if ( out_arg. mode == ast. val) {
3418
+ val = bcx. build. Load ( val) ;
3419
+ } else if ( ty. count_ty_params( out_arg. ty) > 0 u) {
3420
+ check ( out_arg. mode == ast. alias) ;
3421
+ val = bcx. build. PointerCast ( val, llout_arg_ty) ;
3422
+ }
3423
+
3424
+ llargs += val;
3409
3425
b += 1 ;
3410
3426
}
3411
3427
3412
3428
// Arg will be provided when the thunk is invoked.
3413
3429
case ( none[ @ast. expr] ) {
3414
3430
let ValueRef passed_arg = llvm. LLVMGetParam ( llthunk, a) ;
3415
- if ( ty. type_has_dynamic_size( outgoing_arg_tys.
3416
- ( outgoing_arg_index) . ty) ) {
3417
- // Cast to a generic typaram pointer in order to make a
3418
- // type-compatible call.
3431
+
3432
+ if ( ty. count_ty_params( out_arg. ty) > 0 u) {
3433
+ check ( out_arg. mode == ast. alias) ;
3419
3434
passed_arg = bcx. build. PointerCast ( passed_arg,
3420
- T_typaram_ptr ( cx . tn ) ) ;
3435
+ llout_arg_ty ) ;
3421
3436
}
3437
+
3422
3438
llargs += passed_arg;
3423
3439
a += 1 u;
3424
3440
}
0 commit comments