From 9221b9118b96d668e2cf5d701b10c0566aa072e9 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Tue, 23 Feb 2016 21:49:35 +0200 Subject: [PATCH] trans: Pass the Rust type for the closure env in type_of_rust_fn. --- src/librustc_trans/trans/declare.rs | 3 +-- src/librustc_trans/trans/type_of.rs | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/librustc_trans/trans/declare.rs b/src/librustc_trans/trans/declare.rs index 381138431e08..3df33d7d076b 100644 --- a/src/librustc_trans/trans/declare.rs +++ b/src/librustc_trans/trans/declare.rs @@ -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") }; diff --git a/src/librustc_trans/trans/type_of.rs b/src/librustc_trans/trans/type_of.rs index d6eb3769d182..e16f25cfec54 100644 --- a/src/librustc_trans/trans/type_of.rs +++ b/src/librustc_trans/trans/type_of.rs @@ -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, + maybe_env: Option>, 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.