diff options
| author | Patrick Walton <[email protected]> | 2011-02-23 18:39:27 -0800 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-02-24 12:33:08 -0800 |
| commit | 0a65283c5eeae0b98fff7d213dbaad59889e677e (patch) | |
| tree | abd9bba82b09433078eda65c62aa0a880763ac8b /src | |
| parent | Parse crate directive tree in one pass, then evaluate it in a second. (diff) | |
| download | rust-0a65283c5eeae0b98fff7d213dbaad59889e677e.tar.xz rust-0a65283c5eeae0b98fff7d213dbaad59889e677e.zip | |
Cast more aggressively to the callee type when calling generic functions. Add a test-case for this, and XFAIL it in rustboot.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile | 1 | ||||
| -rw-r--r-- | src/comp/middle/trans.rs | 6 | ||||
| -rw-r--r-- | src/test/run-pass/generic-fn-box.rs | 9 |
3 files changed, 13 insertions, 3 deletions
diff --git a/src/Makefile b/src/Makefile index 70b3ca0f..12b65246 100644 --- a/src/Makefile +++ b/src/Makefile @@ -416,6 +416,7 @@ TEST_XFAILS_BOOT := $(TASK_XFAILS) \ test/run-pass/obj-as.rs \ test/run-pass/vec-slice.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-tup.rs \ test/run-pass/iter-ret.rs \ diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 30f3cdc4..72f1106b 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -3132,9 +3132,9 @@ fn trans_args(@block_ctxt cx, bcx = re.bcx; } - if (ty.type_has_dynamic_size(args.(i).ty)) { - val = bcx.build.PointerCast(val, - T_typaram_ptr(cx.fcx.ccx.tn)); + if (ty.count_ty_params(args.(i).ty) > 0u) { + auto lldestty = type_of(cx.fcx.ccx, args.(i).ty); + val = bcx.build.PointerCast(val, lldestty); } llargs += val; diff --git a/src/test/run-pass/generic-fn-box.rs b/src/test/run-pass/generic-fn-box.rs new file mode 100644 index 00000000..e821a784 --- /dev/null +++ b/src/test/run-pass/generic-fn-box.rs @@ -0,0 +1,9 @@ +fn f[T](@T x) -> @T { + ret x; +} + +fn main() { + auto x = f(@3); + log *x; +} + |