rustc: middle: avoid clones in ty_fn_{sig,args}.
This commit is contained in:
parent
4c3ad48c45
commit
01105ffde3
@ -3545,10 +3545,10 @@ pub fn fn_is_variadic(fty: Ty) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
@ -3565,14 +3565,8 @@ pub fn ty_fn_abi(fty: Ty) -> abi::Abi {
|
||||
}
|
||||
|
||||
// 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 {
|
||||
|
@ -334,8 +334,7 @@ pub fn trans_unboxing_shim<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
// 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);
|
||||
@ -919,12 +918,11 @@ fn trans_args_under_call_abi<'blk, 'tcx>(
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user