trans: Pass the Rust type for the closure env in type_of_rust_fn.

This commit is contained in:
Eduard Burtescu 2016-02-23 21:49:35 +02:00
parent 7011e30352
commit 9221b9118b
2 changed files with 4 additions and 6 deletions

View File

@ -111,10 +111,9 @@ pub fn declare_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
ProjectionMode::Any);
function_type = infcx.closure_type(closure_did, substs);
let self_type = base::self_type_for_closure(ccx, closure_did, fn_type);
let llenvironment_type = type_of::type_of_explicit_arg(ccx, self_type);
debug!("declare_rust_fn function_type={:?} self_type={:?}",
function_type, self_type);
(&function_type.sig, Abi::RustCall, Some(llenvironment_type))
(&function_type.sig, Abi::RustCall, Some(self_type))
}
_ => ccx.sess().bug("expected closure or fn")
};

View File

@ -89,7 +89,7 @@ pub fn untuple_arguments<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
llenvironment_type: Option<Type>,
maybe_env: Option<Ty<'tcx>>,
sig: &ty::FnSig<'tcx>,
abi: Abi)
-> Type
@ -131,9 +131,8 @@ pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
};
// Arg 1: Environment
match llenvironment_type {
None => {}
Some(llenvironment_type) => atys.push(llenvironment_type),
if let Some(env_ty) = maybe_env {
atys.push(type_of_explicit_arg(cx, env_ty));
}
// ... then explicit args.