@@ -337,7 +337,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
337
337
) -> ClosureSignatures < ' tcx > {
338
338
debug ! ( "sig_of_closure_no_expectation()" ) ;
339
339
340
- let bound_sig = self . supplied_sig_of_closure ( expr_def_id, decl) ;
340
+ let bound_sig = self . supplied_sig_of_closure ( expr_def_id, decl, body ) ;
341
341
342
342
self . closure_sigs ( expr_def_id, body, bound_sig)
343
343
}
@@ -490,7 +490,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
490
490
//
491
491
// (See comment on `sig_of_closure_with_expectation` for the
492
492
// meaning of these letters.)
493
- let supplied_sig = self . supplied_sig_of_closure ( expr_def_id, decl) ;
493
+ let supplied_sig = self . supplied_sig_of_closure ( expr_def_id, decl, body ) ;
494
494
495
495
debug ! (
496
496
"check_supplied_sig_against_expectation: supplied_sig={:?}" ,
@@ -591,14 +591,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
591
591
& self ,
592
592
expr_def_id : DefId ,
593
593
decl : & hir:: FnDecl ,
594
+ body : & hir:: Body ,
594
595
) -> ty:: PolyFnSig < ' tcx > {
595
596
let astconv: & dyn AstConv < ' _ > = self ;
596
597
597
598
// First, convert the types that the user supplied (if any).
598
599
let supplied_arguments = decl. inputs . iter ( ) . map ( |a| astconv. ast_ty_to_ty ( a) ) ;
599
600
let supplied_return = match decl. output {
600
601
hir:: Return ( ref output) => astconv. ast_ty_to_ty ( & output) ,
601
- hir:: DefaultReturn ( _) => astconv. ty_infer ( None , decl. output . span ( ) ) ,
602
+ hir:: DefaultReturn ( _) => match body. generator_kind {
603
+ // In the case of the async block that we create for a function body,
604
+ // we expect the return type of the block to match that of the enclosing
605
+ // function.
606
+ Some ( hir:: GeneratorKind :: Async ( hir:: AsyncGeneratorKind :: Fn ) ) => {
607
+ debug ! ( "supplied_sig_of_closure: closure is async fn body" ) ;
608
+
609
+ // FIXME
610
+ astconv. ty_infer ( None , decl. output . span ( ) )
611
+ }
612
+
613
+ _ => astconv. ty_infer ( None , decl. output . span ( ) ) ,
614
+ }
602
615
} ;
603
616
604
617
let result = ty:: Binder :: bind ( self . tcx . mk_fn_sig (
0 commit comments