@@ -327,6 +327,11 @@ impl<'tcx> Inliner<'tcx> {
327
327
) -> Option < CallSite < ' tcx > > {
328
328
// Only consider direct calls to functions
329
329
let terminator = bb_data. terminator ( ) ;
330
+
331
+ // FIXME(explicit_tail_calls): figure out if we can inline tail calls
332
+ // (this is different from the other fixme,
333
+ // this one is about tail calls in the caller,
334
+ // rather than the callee)
330
335
if let TerminatorKind :: Call { ref func, target, fn_span, .. } = terminator. kind {
331
336
let func_ty = func. ty ( caller_body, self . tcx ) ;
332
337
if let ty:: FnDef ( def_id, substs) = * func_ty. kind ( ) {
@@ -829,6 +834,13 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> {
829
834
self . cost += LANDINGPAD_PENALTY ;
830
835
}
831
836
}
837
+
838
+ // FIXME(explicit_tail_calls): figure out how exactly functions containing tail calls can be inlined (and if they even should)
839
+ TerminatorKind :: TailCall { .. } => {
840
+ self . validation = Err ( "can't inline functions with tail calls" ) ;
841
+ return ;
842
+ }
843
+
832
844
_ => self . cost += INSTR_COST ,
833
845
}
834
846
@@ -1078,7 +1090,8 @@ impl<'tcx> MutVisitor<'tcx> for Integrator<'_, 'tcx> {
1078
1090
* unwind = self . map_unwind ( * unwind) ;
1079
1091
}
1080
1092
TerminatorKind :: TailCall { .. } => {
1081
- // FIXME(explicit_tail_calls): figure out how exactly tail calls are inlined
1093
+ // Cost checker forbids tail calls
1094
+ unreachable ! ( )
1082
1095
}
1083
1096
TerminatorKind :: Call { ref mut target, ref mut unwind, .. } => {
1084
1097
if let Some ( ref mut tgt) = * target {
0 commit comments