}
}
-pub fn ty_fn_sig<'tcx>(fty: Ty<'tcx>) -> FnSig<'tcx> {
+pub fn ty_fn_sig<'tcx>(fty: Ty<'tcx>) -> &'tcx FnSig<'tcx> {
match get(fty).sty {
- ty_bare_fn(ref f) => f.sig.clone(),
- ty_closure(ref f) => f.sig.clone(),
+ ty_bare_fn(ref f) => &f.sig,
+ ty_closure(ref f) => &f.sig,
ref s => {
panic!("ty_fn_sig() called on non-fn type: {}", s)
}
}
// Type accessors for substructures of types
-pub fn ty_fn_args<'tcx>(fty: Ty<'tcx>) -> Vec<Ty<'tcx>> {
- match get(fty).sty {
- ty_bare_fn(ref f) => f.sig.inputs.clone(),
- ty_closure(ref f) => f.sig.inputs.clone(),
- ref s => {
- panic!("ty_fn_args() called on non-fn type: {}", s)
- }
- }
+pub fn ty_fn_args<'tcx>(fty: Ty<'tcx>) -> &'tcx [Ty<'tcx>] {
+ ty_fn_sig(fty).inputs.as_slice()
}
pub fn ty_closure_store(fty: Ty) -> TraitStore {
// Create the substituted versions of the self type.
let arg_scope = fcx.push_custom_cleanup_scope();
let arg_scope_id = cleanup::CustomScope(arg_scope);
- let boxed_arg_types = ty::ty_fn_args(boxed_function_type);
- let boxed_self_type = boxed_arg_types[0];
+ let boxed_self_type = ty::ty_fn_args(boxed_function_type)[0];
let arg_types = ty::ty_fn_args(function_type);
let self_type = arg_types[0];
let boxed_self_kind = arg_kind(&fcx, boxed_self_type);
ignore_self: bool)
-> Block<'blk, 'tcx> {
// Translate the `self` argument first.
- let arg_tys = ty::ty_fn_args(fn_ty);
if !ignore_self {
let arg_datum = unpack_datum!(bcx, expr::trans(bcx, &*arg_exprs[0]));
llargs.push(unpack_result!(bcx, {
trans_arg_datum(bcx,
- arg_tys[0],
+ ty::ty_fn_args(fn_ty)[0],
arg_datum,
arg_cleanup_scope,
DontAutorefArg)