Remove silly restriction on passing type params by alias

Since they are now passed by pointer, this is no longer a problem
This commit is contained in:
Marijn Haverbeke 2011-08-22 13:19:07 +02:00
parent 10269dfaeb
commit 42864377a4
3 changed files with 2 additions and 21 deletions

View File

@ -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);

View File

@ -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 {

View File

@ -1,9 +0,0 @@
// -*- rust -*-
// error-pattern: Dynamically sized arguments must be passed by alias
mod foo {
fn bar<T>(f: T) -> int { ret 17; }
type bar<U, T> = {a: int, b: U, c: T};
}
fn main() { }