Skip to content

Commit c790bf7

Browse files
committed
Fixup tail call fixmes in mir inliner
1 parent 772f888 commit c790bf7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler/rustc_mir_transform/src/inline.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ impl<'tcx> Inliner<'tcx> {
368368
) -> Option<CallSite<'tcx>> {
369369
// Only consider direct calls to functions
370370
let terminator = bb_data.terminator();
371+
372+
// FIXME(explicit_tail_calls): figure out if we can inline tail calls
371373
if let TerminatorKind::Call { ref func, fn_span, .. } = terminator.kind {
372374
let func_ty = func.ty(caller_body, self.tcx);
373375
if let ty::FnDef(def_id, args) = *func_ty.kind() {
@@ -527,6 +529,9 @@ impl<'tcx> Inliner<'tcx> {
527529
// inline-asm is detected. LLVM will still possibly do an inline later on
528530
// if the no-attribute function ends up with the same instruction set anyway.
529531
return Err("Cannot move inline-asm across instruction sets");
532+
} else if let TerminatorKind::TailCall { .. } = term.kind {
533+
// FIXME(explicit_tail_calls): figure out how exactly functions containing tail calls can be inlined (and if they even should)
534+
return Err("can't inline functions with tail calls");
530535
} else {
531536
work_list.extend(term.successors())
532537
}
@@ -989,7 +994,8 @@ impl<'tcx> MutVisitor<'tcx> for Integrator<'_, 'tcx> {
989994
*unwind = self.map_unwind(*unwind);
990995
}
991996
TerminatorKind::TailCall { .. } => {
992-
// FIXME(explicit_tail_calls): figure out how exactly tail calls are inlined
997+
// check_mir_body forbids tail calls
998+
unreachable!()
993999
}
9941000
TerminatorKind::Call { ref mut target, ref mut unwind, .. } => {
9951001
if let Some(ref mut tgt) = *target {

0 commit comments

Comments
 (0)