@@ -377,7 +377,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
377
377
) -> ClosureSignatures < ' tcx > {
378
378
debug ! ( "sig_of_closure_no_expectation()" ) ;
379
379
380
- let bound_sig = self . supplied_sig_of_closure ( decl) ;
380
+ let bound_sig = self . supplied_sig_of_closure ( expr_def_id , decl) ;
381
381
382
382
self . closure_sigs ( expr_def_id, body, bound_sig)
383
383
}
@@ -479,7 +479,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
479
479
// Along the way, it also writes out entries for types that the user
480
480
// wrote into our tables, which are then later used by the privacy
481
481
// check.
482
- match self . check_supplied_sig_against_expectation ( decl, & closure_sigs) {
482
+ match self . check_supplied_sig_against_expectation ( expr_def_id , decl, & closure_sigs) {
483
483
Ok ( infer_ok) => self . register_infer_ok_obligations ( infer_ok) ,
484
484
Err ( _) => return self . sig_of_closure_no_expectation ( expr_def_id, decl, body) ,
485
485
}
@@ -521,14 +521,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
521
521
/// strategy.
522
522
fn check_supplied_sig_against_expectation (
523
523
& self ,
524
+ expr_def_id : DefId ,
524
525
decl : & hir:: FnDecl ,
525
526
expected_sigs : & ClosureSignatures < ' tcx > ,
526
527
) -> InferResult < ' tcx , ( ) > {
527
528
// Get the signature S that the user gave.
528
529
//
529
530
// (See comment on `sig_of_closure_with_expectation` for the
530
531
// meaning of these letters.)
531
- let supplied_sig = self . supplied_sig_of_closure ( decl) ;
532
+ let supplied_sig = self . supplied_sig_of_closure ( expr_def_id , decl) ;
532
533
533
534
debug ! (
534
535
"check_supplied_sig_against_expectation: supplied_sig={:?}" ,
@@ -598,7 +599,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
598
599
599
600
/// If there is no expected signature, then we will convert the
600
601
/// types that the user gave into a signature.
601
- fn supplied_sig_of_closure ( & self , decl : & hir:: FnDecl ) -> ty:: PolyFnSig < ' tcx > {
602
+ ///
603
+ /// Also, record this closure signature for later.
604
+ fn supplied_sig_of_closure (
605
+ & self ,
606
+ expr_def_id : DefId ,
607
+ decl : & hir:: FnDecl ,
608
+ ) -> ty:: PolyFnSig < ' tcx > {
602
609
let astconv: & dyn AstConv = self ;
603
610
604
611
// First, convert the types that the user supplied (if any).
@@ -618,6 +625,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
618
625
619
626
debug ! ( "supplied_sig_of_closure: result={:?}" , result) ;
620
627
628
+ let c_result = self . inh . infcx . canonicalize_response ( & result) ;
629
+ self . tables . borrow_mut ( ) . user_provided_sigs . insert (
630
+ expr_def_id,
631
+ c_result,
632
+ ) ;
633
+
621
634
result
622
635
}
623
636
0 commit comments