@@ -157,11 +157,13 @@ impl<'tcx> Inliner<'tcx> {
157
157
return Err ( "optimization fuel exhausted" ) ;
158
158
}
159
159
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 (
161
161
self . tcx ,
162
162
self . param_env ,
163
163
callee_body. clone ( ) ,
164
- ) ;
164
+ ) else {
165
+ return Err ( "failed to normalize callee body" ) ;
166
+ } ;
165
167
166
168
let old_blocks = caller_body. basic_blocks ( ) . next_index ( ) ;
167
169
self . inline_call ( caller_body, & callsite, callee_body) ;
@@ -252,7 +254,7 @@ impl<'tcx> Inliner<'tcx> {
252
254
let func_ty = func. ty ( caller_body, self . tcx ) ;
253
255
if let ty:: FnDef ( def_id, substs) = * func_ty. kind ( ) {
254
256
// 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 ( ) ? ;
256
258
let callee =
257
259
Instance :: resolve ( self . tcx , self . param_env , def_id, substs) . ok ( ) . flatten ( ) ?;
258
260
@@ -407,14 +409,17 @@ impl<'tcx> Inliner<'tcx> {
407
409
if let ty:: FnDef ( def_id, substs) =
408
410
* callsite. callee . subst_mir ( self . tcx , & f. literal . ty ( ) ) . kind ( )
409
411
{
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)
413
414
{
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
+ }
418
423
}
419
424
}
420
425
// Don't give intrinsics the extra penalty for calls
0 commit comments