@@ -366,40 +366,44 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
366366 self . check_edge ( location, * target, EdgeKind :: Normal ) ;
367367 self . check_unwind_edge ( location, * unwind) ;
368368 }
369- TerminatorKind :: Call { args, destination, target, unwind, .. } => {
370- if let Some ( target) = target {
371- self . check_edge ( location, * target, EdgeKind :: Normal ) ;
372- }
373- self . check_unwind_edge ( location, * unwind) ;
369+ TerminatorKind :: Call { args, .. } | TerminatorKind :: TailCall { args, .. } => {
370+ // FIXME(explicit_tail_calls): refactor this & add tail-call specific checks
371+ if let TerminatorKind :: Call { target, unwind, destination, .. } = terminator. kind {
372+ if let Some ( target) = target {
373+ self . check_edge ( location, target, EdgeKind :: Normal ) ;
374+ }
375+ self . check_unwind_edge ( location, unwind) ;
376+
377+ // The code generation assumes that there are no critical call edges. The assumption
378+ // is used to simplify inserting code that should be executed along the return edge
379+ // from the call. FIXME(tmiasko): Since this is a strictly code generation concern,
380+ // the code generation should be responsible for handling it.
381+ if self . mir_phase >= MirPhase :: Runtime ( RuntimePhase :: Optimized )
382+ && self . is_critical_call_edge ( target, unwind)
383+ {
384+ self . fail (
385+ location,
386+ format ! (
387+ "encountered critical edge in `Call` terminator {:?}" ,
388+ terminator. kind,
389+ ) ,
390+ ) ;
391+ }
374392
375- // The code generation assumes that there are no critical call edges. The assumption
376- // is used to simplify inserting code that should be executed along the return edge
377- // from the call. FIXME(tmiasko): Since this is a strictly code generation concern,
378- // the code generation should be responsible for handling it.
379- if self . mir_phase >= MirPhase :: Runtime ( RuntimePhase :: Optimized )
380- && self . is_critical_call_edge ( * target, * unwind)
381- {
382- self . fail (
383- location,
384- format ! (
385- "encountered critical edge in `Call` terminator {:?}" ,
386- terminator. kind,
387- ) ,
388- ) ;
393+ // The call destination place and Operand::Move place used as an argument might be
394+ // passed by a reference to the callee. Consequently they cannot be packed.
395+ if is_within_packed ( self . tcx , & self . body . local_decls , destination) . is_some ( ) {
396+ // This is bad! The callee will expect the memory to be aligned.
397+ self . fail (
398+ location,
399+ format ! (
400+ "encountered packed place in `Call` terminator destination: {:?}" ,
401+ terminator. kind,
402+ ) ,
403+ ) ;
404+ }
389405 }
390406
391- // The call destination place and Operand::Move place used as an argument might be
392- // passed by a reference to the callee. Consequently they cannot be packed.
393- if is_within_packed ( self . tcx , & self . body . local_decls , * destination) . is_some ( ) {
394- // This is bad! The callee will expect the memory to be aligned.
395- self . fail (
396- location,
397- format ! (
398- "encountered packed place in `Call` terminator destination: {:?}" ,
399- terminator. kind,
400- ) ,
401- ) ;
402- }
403407 for arg in args {
404408 if let Operand :: Move ( place) = & arg. node {
405409 if is_within_packed ( self . tcx , & self . body . local_decls , * place) . is_some ( ) {
@@ -1291,13 +1295,16 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
12911295 }
12921296 }
12931297 }
1294- TerminatorKind :: Call { func, .. } => {
1298+ TerminatorKind :: Call { func, .. } | TerminatorKind :: TailCall { func , .. } => {
12951299 let func_ty = func. ty ( & self . body . local_decls , self . tcx ) ;
12961300 match func_ty. kind ( ) {
12971301 ty:: FnPtr ( ..) | ty:: FnDef ( ..) => { }
12981302 _ => self . fail (
12991303 location,
1300- format ! ( "encountered non-callable type {func_ty} in `Call` terminator" ) ,
1304+ format ! (
1305+ "encountered non-callable type {func_ty} in `{}` terminator" ,
1306+ terminator. kind. name( )
1307+ ) ,
13011308 ) ,
13021309 }
13031310 }
0 commit comments