@@ -337,7 +337,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
337337 ) -> ClosureSignatures < ' tcx > {
338338 debug ! ( "sig_of_closure_no_expectation()" ) ;
339339
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 ) ;
341341
342342 self . closure_sigs ( expr_def_id, body, bound_sig)
343343 }
@@ -490,7 +490,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
490490 //
491491 // (See comment on `sig_of_closure_with_expectation` for the
492492 // 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 ) ;
494494
495495 debug ! (
496496 "check_supplied_sig_against_expectation: supplied_sig={:?}" ,
@@ -591,14 +591,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
591591 & self ,
592592 expr_def_id : DefId ,
593593 decl : & hir:: FnDecl ,
594+ body : & hir:: Body ,
594595 ) -> ty:: PolyFnSig < ' tcx > {
595596 let astconv: & dyn AstConv < ' _ > = self ;
596597
597598 // First, convert the types that the user supplied (if any).
598599 let supplied_arguments = decl. inputs . iter ( ) . map ( |a| astconv. ast_ty_to_ty ( a) ) ;
599600 let supplied_return = match decl. output {
600601 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+ }
602615 } ;
603616
604617 let result = ty:: Binder :: bind ( self . tcx . mk_fn_sig (
0 commit comments