@@ -31,6 +31,7 @@ struct ExpectedSig<'tcx> {
3131 sig : ty:: PolyFnSig < ' tcx > ,
3232}
3333
34+ #[ derive( Debug ) ]
3435struct ClosureSignatures < ' tcx > {
3536 /// The signature users of the closure see.
3637 bound_sig : ty:: PolyFnSig < ' tcx > ,
@@ -713,25 +714,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
713714 // [c2]: https://github.com/rust-lang/rust/pull/45072#issuecomment-341096796
714715 self . commit_if_ok ( |_| {
715716 let mut all_obligations = vec ! [ ] ;
716- let inputs: Vec < _ > = iter:: zip (
717- decl. inputs ,
718- supplied_sig. inputs ( ) . skip_binder ( ) , // binder moved to (*) below
719- )
720- . map ( |( hir_ty, & supplied_ty) | {
721- // Instantiate (this part of..) S to S', i.e., with fresh variables.
722- self . instantiate_binder_with_fresh_vars (
723- hir_ty. span ,
724- BoundRegionConversionTime :: FnCall ,
725- // (*) binder moved to here
726- supplied_sig. inputs ( ) . rebind ( supplied_ty) ,
727- )
728- } )
729- . collect ( ) ;
717+ let supplied_sig = self . instantiate_binder_with_fresh_vars (
718+ self . tcx . def_span ( expr_def_id) ,
719+ BoundRegionConversionTime :: FnCall ,
720+ supplied_sig,
721+ ) ;
730722
731723 // The liberated version of this signature should be a subtype
732724 // of the liberated form of the expectation.
733725 for ( ( hir_ty, & supplied_ty) , expected_ty) in iter:: zip (
734- iter:: zip ( decl. inputs , & inputs) ,
726+ iter:: zip ( decl. inputs , supplied_sig . inputs ( ) ) ,
735727 expected_sigs. liberated_sig . inputs ( ) , // `liberated_sig` is E'.
736728 ) {
737729 // Check that E' = S'.
@@ -744,11 +736,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
744736 all_obligations. extend ( obligations) ;
745737 }
746738
747- let supplied_output_ty = self . instantiate_binder_with_fresh_vars (
748- decl. output . span ( ) ,
749- BoundRegionConversionTime :: FnCall ,
750- supplied_sig. output ( ) ,
751- ) ;
739+ let supplied_output_ty = supplied_sig. output ( ) ;
752740 let cause = & self . misc ( decl. output . span ( ) ) ;
753741 let InferOk { value : ( ) , obligations } = self . at ( cause, self . param_env ) . eq (
754742 DefineOpaqueTypes :: Yes ,
@@ -757,7 +745,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
757745 ) ?;
758746 all_obligations. extend ( obligations) ;
759747
760- let inputs = inputs. into_iter ( ) . map ( |ty| self . resolve_vars_if_possible ( ty) ) ;
748+ let inputs =
749+ supplied_sig. inputs ( ) . into_iter ( ) . map ( |& ty| self . resolve_vars_if_possible ( ty) ) ;
761750
762751 expected_sigs. liberated_sig = self . tcx . mk_fn_sig (
763752 inputs,
@@ -1013,6 +1002,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10131002 result
10141003 }
10151004
1005+ #[ instrument( level = "debug" , skip( self ) , ret) ]
10161006 fn closure_sigs (
10171007 & self ,
10181008 expr_def_id : LocalDefId ,
0 commit comments