@@ -59,16 +59,36 @@ pub(super) fn check_fn<'a, 'tcx>(
59
59
&& can_be_coroutine. is_some ( )
60
60
{
61
61
let yield_ty = match kind {
62
- hir:: CoroutineKind :: Gen ( ..)
63
- | hir:: CoroutineKind :: AsyncGen ( ..)
64
- | hir:: CoroutineKind :: Coroutine => {
62
+ hir:: CoroutineKind :: Gen ( ..) | hir:: CoroutineKind :: Coroutine => {
65
63
let yield_ty = fcx. next_ty_var ( TypeVariableOrigin {
66
64
kind : TypeVariableOriginKind :: TypeInference ,
67
65
span,
68
66
} ) ;
69
67
fcx. require_type_is_sized ( yield_ty, span, traits:: SizedYieldType ) ;
70
68
yield_ty
71
69
}
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
+ }
72
92
hir:: CoroutineKind :: Async ( ..) => Ty :: new_unit ( tcx) ,
73
93
} ;
74
94
0 commit comments