@@ -204,14 +204,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
204
204
)
205
205
}
206
206
hir:: ClosureKind :: CoroutineClosure ( kind) => {
207
- // async closures always return the type ascribed after the `->` (if present),
208
- // and yield `()`.
209
207
let ( bound_return_ty, bound_yield_ty) = match kind {
208
+ hir:: CoroutineDesugaring :: Gen => {
209
+ // `iter!` closures always return unit and yield the `Iterator::Item` type
210
+ // that we have to infer.
211
+ ( tcx. types . unit , self . infcx . next_ty_var ( expr_span) )
212
+ }
210
213
hir:: CoroutineDesugaring :: Async => {
214
+ // async closures always return the type ascribed after the `->` (if present),
215
+ // and yield `()`.
211
216
( bound_sig. skip_binder ( ) . output ( ) , tcx. types . unit )
212
217
}
213
- hir:: CoroutineDesugaring :: Gen | hir :: CoroutineDesugaring :: AsyncGen => {
214
- todo ! ( "`gen` and ` async gen` closures not supported yet" )
218
+ hir:: CoroutineDesugaring :: AsyncGen => {
219
+ todo ! ( "`async gen` closures not supported yet" )
215
220
}
216
221
} ;
217
222
// Compute all of the variables that will be used to populate the coroutine.
@@ -465,7 +470,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
465
470
466
471
if let Some ( trait_def_id) = trait_def_id {
467
472
let found_kind = match closure_kind {
468
- hir:: ClosureKind :: Closure => self . tcx . fn_trait_kind_from_def_id ( trait_def_id) ,
473
+ hir:: ClosureKind :: Closure
474
+ // FIXME(iter_macro): Someday we'll probably want iterator closures instead of
475
+ // just using Fn* for iterators.
476
+ | hir:: ClosureKind :: CoroutineClosure ( hir:: CoroutineDesugaring :: Gen ) => {
477
+ self . tcx . fn_trait_kind_from_def_id ( trait_def_id)
478
+ }
469
479
hir:: ClosureKind :: CoroutineClosure ( hir:: CoroutineDesugaring :: Async ) => self
470
480
. tcx
471
481
. async_fn_trait_kind_from_def_id ( trait_def_id)
0 commit comments