Rustup to rustc 1.44.0-nightly (45d050cde
2020-04-21)
Remove the `<Box<F> as FnOnce>::call_once` hack now that rust-lang/rust#71170 is merged.
This commit is contained in:
parent
5a6d9e1f1b
commit
27a46ff765
@ -1 +1 @@
|
||||
nightly-2020-04-17
|
||||
nightly-2020-04-22
|
||||
|
81
src/base.rs
81
src/base.rs
@ -58,92 +58,11 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
|
||||
};
|
||||
|
||||
let arg_uninhabited = fx.mir.args_iter().any(|arg| fx.layout_of(fx.monomorphize(&fx.mir.local_decls[arg].ty)).abi.is_uninhabited());
|
||||
let is_call_once_for_box = name.starts_with("_ZN83_$LT$alloc..boxed..Box$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$9call_once");
|
||||
|
||||
if arg_uninhabited {
|
||||
fx.bcx.append_block_params_for_function_params(fx.block_map[START_BLOCK]);
|
||||
fx.bcx.switch_to_block(fx.block_map[START_BLOCK]);
|
||||
crate::trap::trap_unreachable(&mut fx, "function has uninhabited argument");
|
||||
} 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!(),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tcx.sess.time("codegen clif ir", || {
|
||||
tcx.sess.time("codegen prelude", || crate::abi::codegen_fn_prelude(&mut fx, start_block, true));
|
||||
|
Loading…
Reference in New Issue
Block a user