Skip to content

Commit e0871ed

Browse files
committed
record supplied sig of closure
1 parent a8f3d6d commit e0871ed

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/librustc_typeck/check/closure.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
377377
) -> ClosureSignatures<'tcx> {
378378
debug!("sig_of_closure_no_expectation()");
379379

380-
let bound_sig = self.supplied_sig_of_closure(decl);
380+
let bound_sig = self.supplied_sig_of_closure(expr_def_id, decl);
381381

382382
self.closure_sigs(expr_def_id, body, bound_sig)
383383
}
@@ -479,7 +479,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
479479
// Along the way, it also writes out entries for types that the user
480480
// wrote into our tables, which are then later used by the privacy
481481
// 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) {
483483
Ok(infer_ok) => self.register_infer_ok_obligations(infer_ok),
484484
Err(_) => return self.sig_of_closure_no_expectation(expr_def_id, decl, body),
485485
}
@@ -521,14 +521,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
521521
/// strategy.
522522
fn check_supplied_sig_against_expectation(
523523
&self,
524+
expr_def_id: DefId,
524525
decl: &hir::FnDecl,
525526
expected_sigs: &ClosureSignatures<'tcx>,
526527
) -> InferResult<'tcx, ()> {
527528
// Get the signature S that the user gave.
528529
//
529530
// (See comment on `sig_of_closure_with_expectation` for the
530531
// 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);
532533

533534
debug!(
534535
"check_supplied_sig_against_expectation: supplied_sig={:?}",
@@ -598,7 +599,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
598599

599600
/// If there is no expected signature, then we will convert the
600601
/// 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> {
602609
let astconv: &dyn AstConv = self;
603610

604611
// First, convert the types that the user supplied (if any).
@@ -618,6 +625,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
618625

619626
debug!("supplied_sig_of_closure: result={:?}", result);
620627

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+
621634
result
622635
}
623636

0 commit comments

Comments
 (0)