Skip to content

Commit 2d34ad0

Browse files
trans: Make sure that each FnOnce shim is only translated once.
1 parent 4570199 commit 2d34ad0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: src/librustc_trans/closure.rs

+6
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
217217
llreffn: ValueRef)
218218
-> ValueRef
219219
{
220+
if let Some(&llfn) = ccx.instances().borrow().get(&method_instance) {
221+
return llfn;
222+
}
223+
220224
debug!("trans_fn_once_adapter_shim(closure_def_id={:?}, substs={:?}, llreffn={:?})",
221225
closure_def_id, substs, Value(llreffn));
222226

@@ -312,5 +316,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
312316

313317
fcx.finish(bcx, DebugLoc::None);
314318

319+
ccx.instances().borrow_mut().insert(method_instance, lloncefn);
320+
315321
lloncefn
316322
}

0 commit comments

Comments
 (0)