From 42864377a4a64e3d8258e6fdb788c5e322c1ca55 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 22 Aug 2011 13:19:07 +0200 Subject: [PATCH] Remove silly restriction on passing type params by alias Since they are now passed by pointer, this is no longer a problem --- src/comp/middle/trans.rs | 4 ++-- src/comp/middle/typeck.rs | 10 ---------- src/test/compile-fail/item-name-overload.rs | 9 --------- 3 files changed, 2 insertions(+), 21 deletions(-) delete mode 100644 src/test/compile-fail/item-name-overload.rs diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index ddb855e97c84..be3db59561ba 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -4553,7 +4553,7 @@ fn trans_arg_expr(cx: &@block_ctxt, arg: &ty::arg, lldestty0: TypeRef, }; if !lv.is_mem && !is_ext_vec_plus { // Do nothing for temporaries, just give them to callee - } else if ty::type_is_structural(ccx.tcx, e_ty) { + } else if type_is_structural_or_param(ccx.tcx, e_ty) { let dst = alloc_ty(bcx, e_ty); bcx = copy_val(dst.bcx, INIT, dst.val, val, e_ty); val = dst.val; @@ -5906,7 +5906,7 @@ fn copy_args_to_allocas(fcx: @fn_ctxt, scope: @block_ctxt, ast::val. { // Structural types are passed by pointer, and we use the // pointed-to memory for the local. - if !ty::type_is_structural(fcx_tcx(fcx), arg_ty) { + if !type_is_structural_or_param(fcx_tcx(fcx), arg_ty) { // Overwrite the llargs entry for this arg with its alloca. let aval = bcx.fcx.llargs.get(aarg.id); let addr = do_spill(bcx, aval); diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index ff5de77ba0b5..cdbc833dac07 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -593,16 +593,6 @@ mod collect { let ty_mode = ast_mode_to_mode(a.mode); let f = bind getter(cx, _); let tt = ast_ty_to_ty(cx.tcx, f, a.ty); - if ty::type_has_dynamic_size(cx.tcx, tt) { - alt ty_mode { - mo_val. { - cx.tcx.sess.span_err(a.ty.span, - "Dynamically sized arguments \ - must be passed by alias"); - } - _ { } - } - } ret {mode: ty_mode, ty: tt}; } fn ty_of_method(cx: @ctxt, m: &@ast::method) -> ty::method { diff --git a/src/test/compile-fail/item-name-overload.rs b/src/test/compile-fail/item-name-overload.rs deleted file mode 100644 index bb1d8bafcd88..000000000000 --- a/src/test/compile-fail/item-name-overload.rs +++ /dev/null @@ -1,9 +0,0 @@ -// -*- rust -*- -// error-pattern: Dynamically sized arguments must be passed by alias - -mod foo { - fn bar(f: T) -> int { ret 17; } - type bar = {a: int, b: U, c: T}; -} - -fn main() { }