@@ -158,11 +158,13 @@ impl<'tcx> Inliner<'tcx> {
158158 return Err ( "optimization fuel exhausted" ) ;
159159 }
160160
161- let callee_body = callsite. callee . subst_mir_and_normalize_erasing_regions (
161+ let Ok ( callee_body) = callsite. callee . try_subst_mir_and_normalize_erasing_regions (
162162 self . tcx ,
163163 self . param_env ,
164164 callee_body. clone ( ) ,
165- ) ;
165+ ) else {
166+ return Err ( "failed to normalize callee body" ) ;
167+ } ;
166168
167169 let old_blocks = caller_body. basic_blocks ( ) . next_index ( ) ;
168170 self . inline_call ( caller_body, & callsite, callee_body) ;
@@ -253,7 +255,7 @@ impl<'tcx> Inliner<'tcx> {
253255 let func_ty = func. ty ( caller_body, self . tcx ) ;
254256 if let ty:: FnDef ( def_id, substs) = * func_ty. kind ( ) {
255257 // To resolve an instance its substs have to be fully normalized.
256- let substs = self . tcx . normalize_erasing_regions ( self . param_env , substs) ;
258+ let substs = self . tcx . try_normalize_erasing_regions ( self . param_env , substs) . ok ( ) ? ;
257259 let callee =
258260 Instance :: resolve ( self . tcx , self . param_env , def_id, substs) . ok ( ) . flatten ( ) ?;
259261
@@ -408,14 +410,17 @@ impl<'tcx> Inliner<'tcx> {
408410 if let ty:: FnDef ( def_id, substs) =
409411 * callsite. callee . subst_mir ( self . tcx , & f. literal . ty ( ) ) . kind ( )
410412 {
411- let substs = self . tcx . normalize_erasing_regions ( self . param_env , substs) ;
412- if let Ok ( Some ( instance) ) =
413- Instance :: resolve ( self . tcx , self . param_env , def_id, substs)
413+ if let Ok ( substs) =
414+ self . tcx . try_normalize_erasing_regions ( self . param_env , substs)
414415 {
415- if callsite. callee . def_id ( ) == instance. def_id ( ) {
416- return Err ( "self-recursion" ) ;
417- } else if self . history . contains ( & instance) {
418- return Err ( "already inlined" ) ;
416+ if let Ok ( Some ( instance) ) =
417+ Instance :: resolve ( self . tcx , self . param_env , def_id, substs)
418+ {
419+ if callsite. callee . def_id ( ) == instance. def_id ( ) {
420+ return Err ( "self-recursion" ) ;
421+ } else if self . history . contains ( & instance) {
422+ return Err ( "already inlined" ) ;
423+ }
419424 }
420425 }
421426 // Don't give intrinsics the extra penalty for calls
0 commit comments