@@ -588,17 +588,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
588588 & mut self ,
589589 capture_clause : CaptureBy ,
590590 closure_node_id : NodeId ,
591- ret_ty : Option < AstP < Ty > > ,
591+ ret_ty : Option < hir :: FnRetTy < ' hir > > ,
592592 span : Span ,
593593 async_gen_kind : hir:: AsyncGeneratorKind ,
594594 body : impl FnOnce ( & mut Self ) -> hir:: Expr < ' hir > ,
595595 ) -> hir:: ExprKind < ' hir > {
596- let output = match ret_ty {
597- Some ( ty) => hir:: FnRetTy :: Return (
598- self . lower_ty ( & ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: AsyncBlock ) ) ,
599- ) ,
600- None => hir:: FnRetTy :: DefaultReturn ( self . lower_span ( span) ) ,
601- } ;
596+ let output = ret_ty. unwrap_or_else ( || hir:: FnRetTy :: DefaultReturn ( self . lower_span ( span) ) ) ;
602597
603598 // Resume argument type. We let the compiler infer this to simplify the lowering. It is
604599 // fully constrained by `future::from_generator`.
@@ -1003,8 +998,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
1003998 // Transform `async |x: u8| -> X { ... }` into
1004999 // `|x: u8| future_from_generator(|| -> X { ... })`.
10051000 let body_id = this. lower_fn_body ( & outer_decl, |this| {
1006- let async_ret_ty =
1007- if let FnRetTy :: Ty ( ty) = & decl. output { Some ( ty. clone ( ) ) } else { None } ;
1001+ let async_ret_ty = if let FnRetTy :: Ty ( ty) = & decl. output {
1002+ let itctx = ImplTraitContext :: Disallowed ( ImplTraitPosition :: AsyncBlock ) ;
1003+ Some ( hir:: FnRetTy :: Return ( this. lower_ty ( & ty, & itctx) ) )
1004+ } else {
1005+ None
1006+ } ;
1007+
10081008 let async_body = this. make_async_expr (
10091009 capture_clause,
10101010 inner_closure_id,
0 commit comments