@@ -9,7 +9,7 @@ use rustc_hir as hir;
9
9
use rustc_hir:: def:: { CtorOf , DefKind } ;
10
10
use rustc_hir:: lang_items:: LangItem ;
11
11
use rustc_hir:: { Expr , ExprKind , ItemKind , Node , Path , QPath , Stmt , StmtKind , TyKind } ;
12
- use rustc_infer:: infer;
12
+ use rustc_infer:: infer:: { self , TyCtxtInferExt } ;
13
13
use rustc_middle:: lint:: in_external_macro;
14
14
use rustc_middle:: ty:: { self , Binder , Ty } ;
15
15
use rustc_span:: symbol:: { kw, sym} ;
@@ -608,6 +608,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
608
608
let bound_vars = self . tcx . late_bound_vars ( fn_id) ;
609
609
let ty = self . tcx . erase_late_bound_regions ( Binder :: bind_with_vars ( ty, bound_vars) ) ;
610
610
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
+ } ;
611
622
if self . can_coerce ( found, ty) {
612
623
err. multipart_suggestion (
613
624
"you might have meant to return this value" ,
0 commit comments