From 2d34ad04ef6a2a5b69da24ed6b7b2c9f38e4678f Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 4 Oct 2016 16:15:37 -0400 Subject: [PATCH] trans: Make sure that each FnOnce shim is only translated once. --- src/librustc_trans/closure.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/librustc_trans/closure.rs b/src/librustc_trans/closure.rs index d506b47407d7..c87497384ad6 100644 --- a/src/librustc_trans/closure.rs +++ b/src/librustc_trans/closure.rs @@ -217,6 +217,10 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>( llreffn: ValueRef) -> ValueRef { + if let Some(&llfn) = ccx.instances().borrow().get(&method_instance) { + return llfn; + } + debug!("trans_fn_once_adapter_shim(closure_def_id={:?}, substs={:?}, llreffn={:?})", closure_def_id, substs, Value(llreffn)); @@ -312,5 +316,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>( fcx.finish(bcx, DebugLoc::None); + ccx.instances().borrow_mut().insert(method_instance, lloncefn); + lloncefn }