Skip to content

Commit 0a65283

Browse files
committed
Cast more aggressively to the callee type when calling generic functions. Add a test-case for this, and XFAIL it in rustboot.
1 parent 127139a commit 0a65283

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ TEST_XFAILS_BOOT := $(TASK_XFAILS) \
416416
test/run-pass/obj-as.rs \
417417
test/run-pass/vec-slice.rs \
418418
test/run-pass/fn-lval.rs \
419+
test/run-pass/generic-fn-box.rs \
419420
test/run-pass/generic-recursive-tag.rs \
420421
test/run-pass/generic-tup.rs \
421422
test/run-pass/iter-ret.rs \

src/comp/middle/trans.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3132,9 +3132,9 @@ fn trans_args(@block_ctxt cx,
31323132
bcx = re.bcx;
31333133
}
31343134

3135-
if (ty.type_has_dynamic_size(args.(i).ty)) {
3136-
val = bcx.build.PointerCast(val,
3137-
T_typaram_ptr(cx.fcx.ccx.tn));
3135+
if (ty.count_ty_params(args.(i).ty) > 0u) {
3136+
auto lldestty = type_of(cx.fcx.ccx, args.(i).ty);
3137+
val = bcx.build.PointerCast(val, lldestty);
31383138
}
31393139

31403140
llargs += val;

src/test/run-pass/generic-fn-box.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fn f[T](@T x) -> @T {
2+
ret x;
3+
}
4+
5+
fn main() {
6+
auto x = f(@3);
7+
log *x;
8+
}
9+

0 commit comments

Comments
 (0)