@@ -528,12 +528,12 @@ impl<'tcx> Instance<'tcx> {
528
528
def_id : DefId ,
529
529
args : ty:: GenericArgsRef < ' tcx > ,
530
530
requested_kind : ty:: ClosureKind ,
531
- ) -> Option < Instance < ' tcx > > {
531
+ ) -> Instance < ' tcx > {
532
532
let actual_kind = args. as_closure ( ) . kind ( ) ;
533
533
534
534
match needs_fn_once_adapter_shim ( actual_kind, requested_kind) {
535
535
Ok ( true ) => Instance :: fn_once_adapter_instance ( tcx, def_id, args) ,
536
- _ => Some ( Instance :: new ( def_id, args) ) ,
536
+ _ => Instance :: new ( def_id, args) ,
537
537
}
538
538
}
539
539
@@ -548,7 +548,7 @@ impl<'tcx> Instance<'tcx> {
548
548
tcx : TyCtxt < ' tcx > ,
549
549
closure_did : DefId ,
550
550
args : ty:: GenericArgsRef < ' tcx > ,
551
- ) -> Option < Instance < ' tcx > > {
551
+ ) -> Instance < ' tcx > {
552
552
let fn_once = tcx. require_lang_item ( LangItem :: FnOnce , None ) ;
553
553
let call_once = tcx
554
554
. associated_items ( fn_once)
@@ -562,14 +562,12 @@ impl<'tcx> Instance<'tcx> {
562
562
563
563
let self_ty = Ty :: new_closure ( tcx, closure_did, args) ;
564
564
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 ( ) ] ) ;
570
568
571
- debug ! ( ?self_ty, ?sig ) ;
572
- Some ( Instance { def, args } )
569
+ debug ! ( ?self_ty, args=?tupled_inputs_ty . tuple_fields ( ) ) ;
570
+ Instance { def, args }
573
571
}
574
572
575
573
/// Depending on the kind of `InstanceDef`, the MIR body associated with an
0 commit comments