about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-02-24 13:51:53 -0800
committerPatrick Walton <pcwalton@mimiga.net>2011-02-24 14:24:32 -0800
commitdcd65fac199d3caac4b1019304ef5e1b480f31ff (patch)
tree00f11f18239cafd5a2f5f2efa05febc8389201b6 /src
parent5332250d3bddf509994832965f3c5d7b68662ce4 (diff)
downloadrust-dcd65fac199d3caac4b1019304ef5e1b480f31ff.tar.gz
rust-dcd65fac199d3caac4b1019304ef5e1b480f31ff.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/Makefile1
-rw-r--r--src/comp/middle/trans.rs12
-rw-r--r--src/test/run-pass/generic-fn-box.rs9
3 files changed, 19 insertions, 3 deletions
diff --git a/src/Makefile b/src/Makefile
index 70b3ca0f53d..12b65246754 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 30f3cdc4495..a3a1d83fc3e 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -3091,6 +3091,12 @@ fn trans_args(@block_ctxt cx,
     }
 
     // ... 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;
     for (@ast.expr e in es) {
         auto mode = args.(i).mode;
@@ -3132,9 +3138,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 = arg_tys.(i);
+            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 00000000000..e821a784598
--- /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;
+}
+