Skip to content

Commit ba85e78

Browse files
committed
---
yaml --- r: 1558 b: refs/heads/master c: 01bfc3a h: refs/heads/master v: v3
1 parent f072358 commit ba85e78

File tree

5 files changed

+36
-12
lines changed

5 files changed

+36
-12
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: da9ea9ab69ebcf32ff9cc1ad557a6c2a5134bd0d
2+
refs/heads/master: 01bfc3ae8bff5131cfd1db748ca996bdb86e100e

trunk/src/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ TEST_XFAILS_BOOT := $(TASK_XFAILS) \
409409
test/run-pass/obj-as.rs \
410410
test/run-pass/vec-slice.rs \
411411
test/run-pass/fn-lval.rs \
412+
test/run-pass/generic-bind-2.rs \
412413
test/run-pass/generic-fn-box.rs \
413414
test/run-pass/generic-tup.rs \
414415
test/run-pass/iter-ret.rs \

trunk/src/comp/middle/trans.rs

+24-8
Original file line numberDiff line numberDiff line change
@@ -3364,7 +3364,7 @@ fn trans_bind_thunk(@crate_ctxt cx,
33643364
lltargetclosure = bcx.build.Load(lltargetclosure);
33653365

33663366
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);
33683368

33693369
auto llretptr = fcx.llretptr;
33703370
if (ty.type_has_dynamic_size(outgoing_ret_ty)) {
@@ -3392,7 +3392,14 @@ fn trans_bind_thunk(@crate_ctxt cx,
33923392
let uint a = 2u + i; // retptr, task ptr, env come first
33933393
let int b = 0;
33943394
let uint outgoing_arg_index = 0u;
3395+
let vec[TypeRef] llout_arg_tys =
3396+
type_of_explicit_args(cx, outgoing_args);
3397+
33953398
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+
33963403
alt (arg) {
33973404

33983405
// Arg provided at binding time; thunk copies it from closure.
@@ -3403,22 +3410,31 @@ fn trans_bind_thunk(@crate_ctxt cx,
34033410
abi.box_rc_field_body,
34043411
abi.closure_elt_bindings,
34053412
b));
3406-
// FIXME: possibly support passing aliases someday.
3413+
34073414
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) > 0u) {
3420+
check (out_arg.mode == ast.alias);
3421+
val = bcx.build.PointerCast(val, llout_arg_ty);
3422+
}
3423+
3424+
llargs += val;
34093425
b += 1;
34103426
}
34113427

34123428
// Arg will be provided when the thunk is invoked.
34133429
case (none[@ast.expr]) {
34143430
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) > 0u) {
3433+
check (out_arg.mode == ast.alias);
34193434
passed_arg = bcx.build.PointerCast(passed_arg,
3420-
T_typaram_ptr(cx.tn));
3435+
llout_arg_ty);
34213436
}
3437+
34223438
llargs += passed_arg;
34233439
a += 1u;
34243440
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn id[T](&T t) -> T {
2+
ret t;
3+
}
4+
5+
fn main() {
6+
auto t = tup(1,2,3,4,5,6,7);
7+
check (t._5 == 6);
8+
auto f0 = bind id[tup(int,int,int,int,int,int,int)](t);
9+
check (f0()._5 == 6);
10+
}

trunk/src/test/run-pass/generic-bind.rs

-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ fn id[T](&T t) -> T {
55
fn main() {
66
auto t = tup(1,2,3,4,5,6,7);
77
check (t._5 == 6);
8-
// FIXME: this needs to work.
9-
// auto f0 = bind id[tup(int,int,int,int,int,int,int)](t);
108
auto f1 = bind id[tup(int,int,int,int,int,int,int)](_);
11-
// check (f0()._5 == 6);
129
check (f1(t)._5 == 6);
1310
}

0 commit comments

Comments
 (0)