@@ -496,12 +496,12 @@ impl<'tcx> Instance<'tcx> {
496496 def_id : DefId ,
497497 substs : ty:: SubstsRef < ' tcx > ,
498498 requested_kind : ty:: ClosureKind ,
499- ) -> Instance < ' tcx > {
499+ ) -> Option < Instance < ' tcx > > {
500500 let actual_kind = substs. as_closure ( ) . kind ( ) ;
501501
502502 match needs_fn_once_adapter_shim ( actual_kind, requested_kind) {
503503 Ok ( true ) => Instance :: fn_once_adapter_instance ( tcx, def_id, substs) ,
504- _ => Instance :: new ( def_id, substs) ,
504+ _ => Some ( Instance :: new ( def_id, substs) ) ,
505505 }
506506 }
507507
@@ -515,7 +515,7 @@ impl<'tcx> Instance<'tcx> {
515515 tcx : TyCtxt < ' tcx > ,
516516 closure_did : DefId ,
517517 substs : ty:: SubstsRef < ' tcx > ,
518- ) -> Instance < ' tcx > {
518+ ) -> Option < Instance < ' tcx > > {
519519 debug ! ( "fn_once_adapter_shim({:?}, {:?})" , closure_did, substs) ;
520520 let fn_once = tcx. require_lang_item ( LangItem :: FnOnce , None ) ;
521521 let call_once = tcx
@@ -531,12 +531,13 @@ impl<'tcx> Instance<'tcx> {
531531 let self_ty = tcx. mk_closure ( closure_did, substs) ;
532532
533533 let sig = substs. as_closure ( ) . sig ( ) ;
534- let sig = tcx. normalize_erasing_late_bound_regions ( ty:: ParamEnv :: reveal_all ( ) , sig) ;
534+ let sig =
535+ tcx. try_normalize_erasing_late_bound_regions ( ty:: ParamEnv :: reveal_all ( ) , sig) . ok ( ) ?;
535536 assert_eq ! ( sig. inputs( ) . len( ) , 1 ) ;
536537 let substs = tcx. mk_substs_trait ( self_ty, & [ sig. inputs ( ) [ 0 ] . into ( ) ] ) ;
537538
538539 debug ! ( "fn_once_adapter_shim: self_ty={:?} sig={:?}" , self_ty, sig) ;
539- Instance { def, substs }
540+ Some ( Instance { def, substs } )
540541 }
541542
542543 /// Depending on the kind of `InstanceDef`, the MIR body associated with an
0 commit comments