@@ -132,6 +132,7 @@ struct LoweringContext<'a, 'hir> {
132132
133133 allow_try_trait : Lrc < [ Symbol ] > ,
134134 allow_gen_future : Lrc < [ Symbol ] > ,
135+ allow_async_iterator : Lrc < [ Symbol ] > ,
135136
136137 /// Mapping from generics `def_id`s to TAIT generics `def_id`s.
137138 /// For each captured lifetime (e.g., 'a), we create a new lifetime parameter that is a generic
@@ -176,6 +177,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
176177 } else {
177178 [ sym:: gen_future] . into ( )
178179 } ,
180+ // FIXME(gen_blocks): how does `closure_track_caller`
181+ allow_async_iterator : [ sym:: gen_future, sym:: async_iterator] . into ( ) ,
179182 generics_def_id_map : Default :: default ( ) ,
180183 host_param_id : None ,
181184 }
@@ -1900,14 +1903,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19001903 fn_span : Span ,
19011904 ) -> hir:: FnRetTy < ' hir > {
19021905 let span = self . lower_span ( fn_span) ;
1903- let opaque_ty_span = self . mark_span_with_reason ( DesugaringKind :: Async , span, None ) ;
19041906
1905- let opaque_ty_node_id = match coro {
1906- CoroutineKind :: Async { return_impl_trait_id, .. }
1907- | CoroutineKind :: Gen { return_impl_trait_id, .. }
1908- | CoroutineKind :: AsyncGen { return_impl_trait_id, .. } => return_impl_trait_id,
1907+ let ( opaque_ty_node_id, allowed_features) = match coro {
1908+ CoroutineKind :: Async { return_impl_trait_id, .. } => ( return_impl_trait_id, None ) ,
1909+ CoroutineKind :: Gen { return_impl_trait_id, .. } => ( return_impl_trait_id, None ) ,
1910+ CoroutineKind :: AsyncGen { return_impl_trait_id, .. } => {
1911+ ( return_impl_trait_id, Some ( self . allow_async_iterator . clone ( ) ) )
1912+ }
19091913 } ;
19101914
1915+ let opaque_ty_span =
1916+ self . mark_span_with_reason ( DesugaringKind :: Async , span, allowed_features) ;
1917+
19111918 let captured_lifetimes: Vec < _ > = self
19121919 . resolver
19131920 . take_extra_lifetime_params ( opaque_ty_node_id)
@@ -1926,7 +1933,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19261933 let bound = this. lower_coroutine_fn_output_type_to_bound (
19271934 output,
19281935 coro,
1929- span ,
1936+ opaque_ty_span ,
19301937 ImplTraitContext :: ReturnPositionOpaqueTy {
19311938 origin : hir:: OpaqueTyOrigin :: FnReturn ( fn_def_id) ,
19321939 fn_kind,
@@ -1945,7 +1952,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19451952 & mut self ,
19461953 output : & FnRetTy ,
19471954 coro : CoroutineKind ,
1948- span : Span ,
1955+ opaque_ty_span : Span ,
19491956 nested_impl_trait_context : ImplTraitContext ,
19501957 ) -> hir:: GenericBound < ' hir > {
19511958 // Compute the `T` in `Future<Output = T>` from the return type.
@@ -1968,14 +1975,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19681975
19691976 let future_args = self . arena . alloc ( hir:: GenericArgs {
19701977 args : & [ ] ,
1971- bindings : arena_vec ! [ self ; self . assoc_ty_binding( assoc_ty_name, span , output_ty) ] ,
1978+ bindings : arena_vec ! [ self ; self . assoc_ty_binding( assoc_ty_name, opaque_ty_span , output_ty) ] ,
19721979 parenthesized : hir:: GenericArgsParentheses :: No ,
19731980 span_ext : DUMMY_SP ,
19741981 } ) ;
19751982
19761983 hir:: GenericBound :: LangItemTrait (
19771984 trait_lang_item,
1978- self . lower_span ( span ) ,
1985+ opaque_ty_span ,
19791986 self . next_id ( ) ,
19801987 future_args,
19811988 )
0 commit comments