11use rustc_hir:: LangItem ;
22use rustc_middle:: mir:: { Const , ConstValue , UnwindAction , * } ;
3- use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
3+ use rustc_middle:: ty:: { self , InstanceKind , Ty , TyCtxt } ;
44use rustc_span:: Span ;
55use rustc_target:: spec:: PanicStrategy ;
66use tracing:: { debug, instrument} ;
@@ -14,7 +14,7 @@ impl<'tcx> crate::MirPass<'tcx> for PanicEntrypoints {
1414
1515 #[ instrument( level = "trace" , skip( self , tcx, body) ) ]
1616 fn run_pass ( & self , tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
17- if tcx . is_panic_entrypoint ( body. source . def_id ( ) ) {
17+ if body. source . instance . is_panic_entrypoint ( tcx ) {
1818 debug ! ( "Replacing body of {:?}" , body. source) ;
1919 let blocks = body. basic_blocks . as_mut ( ) ;
2020 blocks. raw . clear ( ) ;
@@ -27,13 +27,10 @@ impl<'tcx> crate::MirPass<'tcx> for PanicEntrypoints {
2727 let TerminatorKind :: Call { func, .. } = & mut terminator. kind else {
2828 continue ;
2929 } ;
30- let Operand :: Constant ( box ConstOperand { const_ , .. } ) = & func else {
30+ let Some ( ( def_id , _args ) ) = func. const_fn_def ( ) else {
3131 continue ;
3232 } ;
33- let ty:: FnDef ( def_id, _) = * const_. ty ( ) . kind ( ) else {
34- continue ;
35- } ;
36- if tcx. is_panic_entrypoint ( def_id) {
33+ if InstanceKind :: Item ( def_id) . is_panic_entrypoint ( tcx) {
3734 debug ! ( "Remapping call from {:?} to {:?}" , body. source, def_id) ;
3835 * terminator = abort_terminator ( tcx, terminator. source_info . span ) ;
3936 }
0 commit comments