Cast more aggressively to the callee type when calling generic functions. Add a test-case for this, and XFAIL it in rustboot.
This commit is contained in:
parent
5332250d3b
commit
dcd65fac19
3 changed files with 19 additions and 3 deletions
|
@ -416,6 +416,7 @@ TEST_XFAILS_BOOT := $(TASK_XFAILS) \
|
||||||
test/run-pass/obj-as.rs \
|
test/run-pass/obj-as.rs \
|
||||||
test/run-pass/vec-slice.rs \
|
test/run-pass/vec-slice.rs \
|
||||||
test/run-pass/fn-lval.rs \
|
test/run-pass/fn-lval.rs \
|
||||||
|
test/run-pass/generic-fn-box.rs \
|
||||||
test/run-pass/generic-recursive-tag.rs \
|
test/run-pass/generic-recursive-tag.rs \
|
||||||
test/run-pass/generic-tup.rs \
|
test/run-pass/generic-tup.rs \
|
||||||
test/run-pass/iter-ret.rs \
|
test/run-pass/iter-ret.rs \
|
||||||
|
|
|
@ -3091,6 +3091,12 @@ fn trans_args(@block_ctxt cx,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ... then explicit args.
|
// ... then explicit args.
|
||||||
|
|
||||||
|
// First we figure out the caller's view of the types of the arguments.
|
||||||
|
// This will be needed if this is a generic call, because the callee has
|
||||||
|
// to cast her view of the arguments to the caller's view.
|
||||||
|
auto arg_tys = type_of_explicit_args(cx.fcx.ccx, args);
|
||||||
|
|
||||||
auto i = 0u;
|
auto i = 0u;
|
||||||
for (@ast.expr e in es) {
|
for (@ast.expr e in es) {
|
||||||
auto mode = args.(i).mode;
|
auto mode = args.(i).mode;
|
||||||
|
@ -3132,9 +3138,9 @@ fn trans_args(@block_ctxt cx,
|
||||||
bcx = re.bcx;
|
bcx = re.bcx;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ty.type_has_dynamic_size(args.(i).ty)) {
|
if (ty.count_ty_params(args.(i).ty) > 0u) {
|
||||||
val = bcx.build.PointerCast(val,
|
auto lldestty = arg_tys.(i);
|
||||||
T_typaram_ptr(cx.fcx.ccx.tn));
|
val = bcx.build.PointerCast(val, lldestty);
|
||||||
}
|
}
|
||||||
|
|
||||||
llargs += val;
|
llargs += val;
|
||||||
|
|
9
src/test/run-pass/generic-fn-box.rs
Normal file
9
src/test/run-pass/generic-fn-box.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
fn f[T](@T x) -> @T {
|
||||||
|
ret x;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
auto x = f(@3);
|
||||||
|
log *x;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue