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