@@ -496,12 +496,12 @@ impl<'tcx> Instance<'tcx> {
496
496
def_id : DefId ,
497
497
substs : ty:: SubstsRef < ' tcx > ,
498
498
requested_kind : ty:: ClosureKind ,
499
- ) -> Instance < ' tcx > {
499
+ ) -> Option < Instance < ' tcx > > {
500
500
let actual_kind = substs. as_closure ( ) . kind ( ) ;
501
501
502
502
match needs_fn_once_adapter_shim ( actual_kind, requested_kind) {
503
503
Ok ( true ) => Instance :: fn_once_adapter_instance ( tcx, def_id, substs) ,
504
- _ => Instance :: new ( def_id, substs) ,
504
+ _ => Some ( Instance :: new ( def_id, substs) ) ,
505
505
}
506
506
}
507
507
@@ -515,7 +515,7 @@ impl<'tcx> Instance<'tcx> {
515
515
tcx : TyCtxt < ' tcx > ,
516
516
closure_did : DefId ,
517
517
substs : ty:: SubstsRef < ' tcx > ,
518
- ) -> Instance < ' tcx > {
518
+ ) -> Option < Instance < ' tcx > > {
519
519
debug ! ( "fn_once_adapter_shim({:?}, {:?})" , closure_did, substs) ;
520
520
let fn_once = tcx. require_lang_item ( LangItem :: FnOnce , None ) ;
521
521
let call_once = tcx
@@ -531,12 +531,13 @@ impl<'tcx> Instance<'tcx> {
531
531
let self_ty = tcx. mk_closure ( closure_did, substs) ;
532
532
533
533
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 ( ) ?;
535
536
assert_eq ! ( sig. inputs( ) . len( ) , 1 ) ;
536
537
let substs = tcx. mk_substs_trait ( self_ty, & [ sig. inputs ( ) [ 0 ] . into ( ) ] ) ;
537
538
538
539
debug ! ( "fn_once_adapter_shim: self_ty={:?} sig={:?}" , self_ty, sig) ;
539
- Instance { def, substs }
540
+ Some ( Instance { def, substs } )
540
541
}
541
542
542
543
/// Depending on the kind of `InstanceDef`, the MIR body associated with an
0 commit comments