@@ -59,16 +59,36 @@ pub(super) fn check_fn<'a, 'tcx>(
5959 && can_be_coroutine. is_some ( )
6060 {
6161 let yield_ty = match kind {
62- hir:: CoroutineKind :: Gen ( ..)
63- | hir:: CoroutineKind :: AsyncGen ( ..)
64- | hir:: CoroutineKind :: Coroutine => {
62+ hir:: CoroutineKind :: Gen ( ..) | hir:: CoroutineKind :: Coroutine => {
6563 let yield_ty = fcx. next_ty_var ( TypeVariableOrigin {
6664 kind : TypeVariableOriginKind :: TypeInference ,
6765 span,
6866 } ) ;
6967 fcx. require_type_is_sized ( yield_ty, span, traits:: SizedYieldType ) ;
7068 yield_ty
7169 }
70+ // HACK(-Ztrait-solver=next): In the *old* trait solver, we must eagerly
71+ // guide inference on the yield type so that we can handle `AsyncIterator`
72+ // in this block in projection correctly. In the new trait solver, it is
73+ // not a problem.
74+ hir:: CoroutineKind :: AsyncGen ( ..) => {
75+ let yield_ty = fcx. next_ty_var ( TypeVariableOrigin {
76+ kind : TypeVariableOriginKind :: TypeInference ,
77+ span,
78+ } ) ;
79+ fcx. require_type_is_sized ( yield_ty, span, traits:: SizedYieldType ) ;
80+
81+ Ty :: new_adt (
82+ tcx,
83+ tcx. adt_def ( tcx. require_lang_item ( hir:: LangItem :: Poll , Some ( span) ) ) ,
84+ tcx. mk_args ( & [ Ty :: new_adt (
85+ tcx,
86+ tcx. adt_def ( tcx. require_lang_item ( hir:: LangItem :: Option , Some ( span) ) ) ,
87+ tcx. mk_args ( & [ yield_ty. into ( ) ] ) ,
88+ )
89+ . into ( ) ] ) ,
90+ )
91+ }
7292 hir:: CoroutineKind :: Async ( ..) => Ty :: new_unit ( tcx) ,
7393 } ;
7494
0 commit comments