trans: Make sure that each FnOnce shim is only translated once.

This commit is contained in:
Michael Woerister 2016-10-04 16:15:37 -04:00
parent 457019967b
commit 2d34ad04ef

View file

@ -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
}