Skip to content

Commit 2091084

Browse files
Inline FnOnce once again
1 parent d4b9afa commit 2091084

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

compiler/rustc_mir_transform/src/inline.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -625,13 +625,6 @@ fn try_inlining<'tcx, I: Inliner<'tcx>>(
625625
return Err("implementation limitation -- return type mismatch");
626626
}
627627
if callsite.fn_sig.abi() == ExternAbi::RustCall {
628-
// FIXME: Don't inline user-written `extern "rust-call"` functions,
629-
// since this is generally perf-negative on rustc, and we hope that
630-
// LLVM will inline these functions instead.
631-
if callee_body.spread_arg.is_some() {
632-
return Err("user-written rust-call functions");
633-
}
634-
635628
let (self_arg, arg_tuple) = match &args[..] {
636629
[arg_tuple] => (None, arg_tuple),
637630
[self_arg, arg_tuple] => (Some(self_arg), arg_tuple),
@@ -641,18 +634,23 @@ fn try_inlining<'tcx, I: Inliner<'tcx>>(
641634
let self_arg_ty = self_arg.map(|self_arg| self_arg.node.ty(&caller_body.local_decls, tcx));
642635

643636
let arg_tuple_ty = arg_tuple.node.ty(&caller_body.local_decls, tcx);
644-
let ty::Tuple(arg_tuple_tys) = *arg_tuple_ty.kind() else {
645-
bug!("Closure arguments are not passed as a tuple");
637+
let arg_tys = if callee_body.spread_arg.is_some() {
638+
std::slice::from_ref(&arg_tuple_ty)
639+
} else {
640+
let ty::Tuple(arg_tuple_tys) = *arg_tuple_ty.kind() else {
641+
bug!("Closure arguments are not passed as a tuple");
642+
};
643+
arg_tuple_tys.as_slice()
646644
};
647645

648646
for (arg_ty, input) in
649-
self_arg_ty.into_iter().chain(arg_tuple_tys).zip(callee_body.args_iter())
647+
self_arg_ty.into_iter().chain(arg_tys.iter().copied()).zip(callee_body.args_iter())
650648
{
651649
let input_type = callee_body.local_decls[input].ty;
652650
if !util::sub_types(tcx, inliner.typing_env(), input_type, arg_ty) {
653651
trace!(?arg_ty, ?input_type);
654652
debug!("failed to normalize tuple argument type");
655-
return Err("implementation limitation -- arg mismatch");
653+
return Err("implementation limitation");
656654
}
657655
}
658656
} else {
@@ -1059,8 +1057,7 @@ fn make_call_args<'tcx, I: Inliner<'tcx>>(
10591057

10601058
closure_ref_arg.chain(tuple_tmp_args).collect()
10611059
} else {
1062-
// FIXME(edition_2024): switch back to a normal method call.
1063-
<_>::into_iter(args)
1060+
args.into_iter()
10641061
.map(|a| create_temp_if_necessary(inliner, a.node, callsite, caller_body, return_block))
10651062
.collect()
10661063
}

0 commit comments

Comments
 (0)