- } else if is_call_once_for_box {
- // HACK implement `<Box<F> as FnOnce>::call_once` without `alloca`.
- tcx.sess.time("codegen prelude", || crate::abi::codegen_fn_prelude(&mut fx, start_block, false));
- fx.bcx.switch_to_block(fx.block_map[START_BLOCK]);
- let bb_data = &fx.mir.basic_blocks()[START_BLOCK];
- let destination = match &bb_data.terminator().kind {
- TerminatorKind::Call {
- func,
- args,
- destination,
- cleanup: _,
- from_hir_call: _,
- } => {
- assert_eq!(args.len(), 2);
-
- let closure_arg = Local::new(1);
- let closure_local = args[0].place().unwrap().as_local().unwrap();
- assert_eq!(fx.mir.local_decls[closure_local].ty, fx.mir.local_decls[closure_arg].ty.builtin_deref(true).unwrap().ty);
- let closure_deref = fx.local_map[&closure_arg].place_deref(&mut fx);
- fx.local_map.insert(closure_local, closure_deref);
-
- let args_arg = Local::new(2);
- let args_local = args[1].place().unwrap().as_local().unwrap();
- assert_eq!(fx.mir.local_decls[args_local].ty, fx.mir.local_decls[args_arg].ty);
- fx.local_map.insert(args_local, fx.local_map[&args_arg]);
-
- fx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call(
- &mut fx,
- bb_data.terminator().source_info.span,
- func,
- args,
- destination,
- ));
- destination.map(|(_ret_place, ret_block)| ret_block)
- }
- _ => unreachable!(),
- };
-
- let destination = if let Some(destination) = destination {
- fx.bcx.switch_to_block(fx.block_map[destination]);
- let bb_data = &fx.mir.basic_blocks()[destination];
- match &bb_data.terminator().kind {
- TerminatorKind::Call {
- func,
- args,
- destination,
- cleanup: _,
- from_hir_call: _,
- } => {
- match destination {
- Some((ret_place, _ret_block)) => {
- fx.local_map.insert(ret_place.as_local().unwrap(), CPlace::no_place(fx.layout_of(fx.tcx.mk_unit())));
- }
- None => {}
- }
-
- assert_eq!(args.len(), 1);
- fx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call(
- &mut fx,
- bb_data.terminator().source_info.span,
- func,
- args,
- destination,
- ));
- destination.map(|(_ret_place, ret_block)| ret_block)
- }
- _ => unreachable!(),
- }
- } else {
- None
- };
-
- if let Some(destination) = destination {
- fx.bcx.switch_to_block(fx.block_map[destination]);
- let bb_data = &fx.mir.basic_blocks()[destination];
- match &bb_data.terminator().kind {
- TerminatorKind::Return => crate::abi::codegen_return(&mut fx),
- _ => unreachable!(),
- }
- }