@@ -9,7 +9,7 @@ use rustc_hir as hir;
99use rustc_hir:: def:: { CtorOf , DefKind } ;
1010use rustc_hir:: lang_items:: LangItem ;
1111use rustc_hir:: { Expr , ExprKind , ItemKind , Node , Path , QPath , Stmt , StmtKind , TyKind } ;
12- use rustc_infer:: infer;
12+ use rustc_infer:: infer:: { self , TyCtxtInferExt } ;
1313use rustc_middle:: lint:: in_external_macro;
1414use rustc_middle:: ty:: { self , Binder , Ty } ;
1515use rustc_span:: symbol:: { kw, sym} ;
@@ -608,6 +608,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
608608 let bound_vars = self . tcx . late_bound_vars ( fn_id) ;
609609 let ty = self . tcx . erase_late_bound_regions ( Binder :: bind_with_vars ( ty, bound_vars) ) ;
610610 let ty = self . normalize_associated_types_in ( expr. span , ty) ;
611+ let ty = match self . tcx . asyncness ( fn_id. owner ) {
612+ hir:: IsAsync :: Async => self . tcx . infer_ctxt ( ) . enter ( |infcx| {
613+ infcx. get_impl_future_output_ty ( ty) . unwrap_or_else ( || {
614+ span_bug ! (
615+ fn_decl. output. span( ) ,
616+ "failed to get output type of async function"
617+ )
618+ } )
619+ } ) ,
620+ hir:: IsAsync :: NotAsync => ty,
621+ } ;
611622 if self . can_coerce ( found, ty) {
612623 err. multipart_suggestion (
613624 "you might have meant to return this value" ,
0 commit comments