@@ -31,6 +31,7 @@ struct ExpectedSig<'tcx> {
31
31
sig : ty:: PolyFnSig < ' tcx > ,
32
32
}
33
33
34
+ #[ derive( Debug ) ]
34
35
struct ClosureSignatures < ' tcx > {
35
36
/// The signature users of the closure see.
36
37
bound_sig : ty:: PolyFnSig < ' tcx > ,
@@ -713,25 +714,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
713
714
// [c2]: https://github.com/rust-lang/rust/pull/45072#issuecomment-341096796
714
715
self . commit_if_ok ( |_| {
715
716
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
+ ) ;
730
722
731
723
// The liberated version of this signature should be a subtype
732
724
// of the liberated form of the expectation.
733
725
for ( ( hir_ty, & supplied_ty) , expected_ty) in iter:: zip (
734
- iter:: zip ( decl. inputs , & inputs) ,
726
+ iter:: zip ( decl. inputs , supplied_sig . inputs ( ) ) ,
735
727
expected_sigs. liberated_sig . inputs ( ) , // `liberated_sig` is E'.
736
728
) {
737
729
// Check that E' = S'.
@@ -744,11 +736,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
744
736
all_obligations. extend ( obligations) ;
745
737
}
746
738
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 ( ) ;
752
740
let cause = & self . misc ( decl. output . span ( ) ) ;
753
741
let InferOk { value : ( ) , obligations } = self . at ( cause, self . param_env ) . eq (
754
742
DefineOpaqueTypes :: Yes ,
@@ -757,7 +745,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
757
745
) ?;
758
746
all_obligations. extend ( obligations) ;
759
747
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) ) ;
761
750
762
751
expected_sigs. liberated_sig = self . tcx . mk_fn_sig (
763
752
inputs,
@@ -1013,6 +1002,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1013
1002
result
1014
1003
}
1015
1004
1005
+ #[ instrument( level = "debug" , skip( self ) , ret) ]
1016
1006
fn closure_sigs (
1017
1007
& self ,
1018
1008
expr_def_id : LocalDefId ,
0 commit comments