@@ -528,12 +528,12 @@ impl<'tcx> Instance<'tcx> {
528528 def_id : DefId ,
529529 args : ty:: GenericArgsRef < ' tcx > ,
530530 requested_kind : ty:: ClosureKind ,
531- ) -> Option < Instance < ' tcx > > {
531+ ) -> Instance < ' tcx > {
532532 let actual_kind = args. as_closure ( ) . kind ( ) ;
533533
534534 match needs_fn_once_adapter_shim ( actual_kind, requested_kind) {
535535 Ok ( true ) => Instance :: fn_once_adapter_instance ( tcx, def_id, args) ,
536- _ => Some ( Instance :: new ( def_id, args) ) ,
536+ _ => Instance :: new ( def_id, args) ,
537537 }
538538 }
539539
@@ -548,7 +548,7 @@ impl<'tcx> Instance<'tcx> {
548548 tcx : TyCtxt < ' tcx > ,
549549 closure_did : DefId ,
550550 args : ty:: GenericArgsRef < ' tcx > ,
551- ) -> Option < Instance < ' tcx > > {
551+ ) -> Instance < ' tcx > {
552552 let fn_once = tcx. require_lang_item ( LangItem :: FnOnce , None ) ;
553553 let call_once = tcx
554554 . associated_items ( fn_once)
@@ -562,14 +562,12 @@ impl<'tcx> Instance<'tcx> {
562562
563563 let self_ty = Ty :: new_closure ( tcx, closure_did, args) ;
564564
565- let sig = args. as_closure ( ) . sig ( ) ;
566- let sig =
567- tcx. try_normalize_erasing_late_bound_regions ( ty:: ParamEnv :: reveal_all ( ) , sig) . ok ( ) ?;
568- assert_eq ! ( sig. inputs( ) . len( ) , 1 ) ;
569- let args = tcx. mk_args_trait ( self_ty, [ sig. inputs ( ) [ 0 ] . into ( ) ] ) ;
565+ let tupled_inputs_ty = args. as_closure ( ) . sig ( ) . map_bound ( |sig| sig. inputs ( ) [ 0 ] ) ;
566+ let tupled_inputs_ty = tcx. instantiate_bound_regions_with_erased ( tupled_inputs_ty) ;
567+ let args = tcx. mk_args_trait ( self_ty, [ tupled_inputs_ty. into ( ) ] ) ;
570568
571- debug ! ( ?self_ty, ?sig ) ;
572- Some ( Instance { def, args } )
569+ debug ! ( ?self_ty, args=?tupled_inputs_ty . tuple_fields ( ) ) ;
570+ Instance { def, args }
573571 }
574572
575573 /// Depending on the kind of `InstanceDef`, the MIR body associated with an
0 commit comments