@@ -157,11 +157,13 @@ impl<'tcx> Inliner<'tcx> {
157157 return Err ( "optimization fuel exhausted" ) ;
158158 }
159159
160- let callee_body = callsite. callee . subst_mir_and_normalize_erasing_regions (
160+ let Ok ( callee_body) = callsite. callee . try_subst_mir_and_normalize_erasing_regions (
161161 self . tcx ,
162162 self . param_env ,
163163 callee_body. clone ( ) ,
164- ) ;
164+ ) else {
165+ return Err ( "failed to normalize callee body" ) ;
166+ } ;
165167
166168 let old_blocks = caller_body. basic_blocks ( ) . next_index ( ) ;
167169 self . inline_call ( caller_body, & callsite, callee_body) ;
@@ -252,7 +254,7 @@ impl<'tcx> Inliner<'tcx> {
252254 let func_ty = func. ty ( caller_body, self . tcx ) ;
253255 if let ty:: FnDef ( def_id, substs) = * func_ty. kind ( ) {
254256 // To resolve an instance its substs have to be fully normalized.
255- let substs = self . tcx . normalize_erasing_regions ( self . param_env , substs) ;
257+ let substs = self . tcx . try_normalize_erasing_regions ( self . param_env , substs) . ok ( ) ? ;
256258 let callee =
257259 Instance :: resolve ( self . tcx , self . param_env , def_id, substs) . ok ( ) . flatten ( ) ?;
258260
@@ -407,14 +409,17 @@ impl<'tcx> Inliner<'tcx> {
407409 if let ty:: FnDef ( def_id, substs) =
408410 * callsite. callee . subst_mir ( self . tcx , & f. literal . ty ( ) ) . kind ( )
409411 {
410- let substs = self . tcx . normalize_erasing_regions ( self . param_env , substs) ;
411- if let Ok ( Some ( instance) ) =
412- Instance :: resolve ( self . tcx , self . param_env , def_id, substs)
412+ if let Ok ( substs) =
413+ self . tcx . try_normalize_erasing_regions ( self . param_env , substs)
413414 {
414- if callsite. callee . def_id ( ) == instance. def_id ( ) {
415- return Err ( "self-recursion" ) ;
416- } else if self . history . contains ( & instance) {
417- return Err ( "already inlined" ) ;
415+ if let Ok ( Some ( instance) ) =
416+ Instance :: resolve ( self . tcx , self . param_env , def_id, substs)
417+ {
418+ if callsite. callee . def_id ( ) == instance. def_id ( ) {
419+ return Err ( "self-recursion" ) ;
420+ } else if self . history . contains ( & instance) {
421+ return Err ( "already inlined" ) ;
422+ }
418423 }
419424 }
420425 // Don't give intrinsics the extra penalty for calls
0 commit comments