@@ -865,6 +865,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
865865 } ;
866866
867867 let features = match await_kind {
868+ FutureKind :: Future if is_async_gen => Some ( Arc :: clone ( & self . allow_async_gen ) ) ,
868869 FutureKind :: Future => None ,
869870 FutureKind :: AsyncIterator => Some ( Arc :: clone ( & self . allow_for_await ) ) ,
870871 } ;
@@ -1479,7 +1480,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14791480 fn lower_expr_range_closed ( & mut self , span : Span , e1 : & Expr , e2 : & Expr ) -> hir:: ExprKind < ' hir > {
14801481 let e1 = self . lower_expr_mut ( e1) ;
14811482 let e2 = self . lower_expr_mut ( e2) ;
1482- let fn_path = hir :: QPath :: LangItem ( hir:: LangItem :: RangeInclusiveNew , span) ;
1483+ let fn_path = self . make_lang_item_qpath ( hir:: LangItem :: RangeInclusiveNew , span, None ) ;
14831484 let fn_expr = self . arena . alloc ( self . expr ( span, hir:: ExprKind :: Path ( fn_path) ) ) ;
14841485 hir:: ExprKind :: Call ( fn_expr, arena_vec ! [ self ; e1, e2] )
14851486 }
@@ -1565,7 +1566,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15651566 ) ;
15661567
15671568 hir:: ExprKind :: Struct (
1568- self . arena . alloc ( hir :: QPath :: LangItem ( lang_item, span) ) ,
1569+ self . arena . alloc ( self . make_lang_item_qpath ( lang_item, span, None ) ) ,
15691570 fields,
15701571 hir:: StructTailExpr :: None ,
15711572 )
@@ -1715,8 +1716,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
17151716 // `yield $expr` is transformed into `task_context = yield async_gen_ready($expr)`.
17161717 // This ensures that we store our resumed `ResumeContext` correctly, and also that
17171718 // the apparent value of the `yield` expression is `()`.
1718- let wrapped_yielded = self . expr_call_lang_item_fn (
1719+ let desugar_span = self . mark_span_with_reason (
1720+ DesugaringKind :: Async ,
17191721 span,
1722+ Some ( Arc :: clone ( & self . allow_async_gen ) ) ,
1723+ ) ;
1724+ let wrapped_yielded = self . expr_call_lang_item_fn (
1725+ desugar_span,
17201726 hir:: LangItem :: AsyncGenReady ,
17211727 std:: slice:: from_ref ( yielded) ,
17221728 ) ;
@@ -1728,7 +1734,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
17281734 unreachable ! ( "use of `await` outside of an async context." ) ;
17291735 } ;
17301736 let task_context_ident = Ident :: with_dummy_span ( sym:: _task_context) ;
1731- let lhs = self . expr_ident ( span , task_context_ident, task_context_hid) ;
1737+ let lhs = self . expr_ident ( desugar_span , task_context_ident, task_context_hid) ;
17321738
17331739 hir:: ExprKind :: Assign ( lhs, yield_expr, self . lower_span ( span) )
17341740 } else {
@@ -2161,7 +2167,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
21612167 lang_item : hir:: LangItem ,
21622168 fields : & ' hir [ hir:: Expr < ' hir > ] ,
21632169 ) -> hir:: Expr < ' hir > {
2164- let path = self . arena . alloc ( self . lang_item_path ( span, lang_item ) ) ;
2170+ let path = self . arena . alloc ( self . make_lang_item_qpath ( lang_item , span, None ) ) ;
21652171 self . expr_enum_variant ( span, path, fields)
21662172 }
21672173
@@ -2198,16 +2204,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
21982204 span : Span ,
21992205 lang_item : hir:: LangItem ,
22002206 ) -> hir:: Expr < ' hir > {
2201- let path = self . lang_item_path ( span, lang_item) ;
2202- self . expr ( span, hir:: ExprKind :: Path ( path) )
2203- }
2204-
2205- pub ( super ) fn lang_item_path (
2206- & mut self ,
2207- span : Span ,
2208- lang_item : hir:: LangItem ,
2209- ) -> hir:: QPath < ' hir > {
2210- hir:: QPath :: LangItem ( lang_item, self . lower_span ( span) )
2207+ let qpath = self . make_lang_item_qpath ( lang_item, self . lower_span ( span) , None ) ;
2208+ self . expr ( span, hir:: ExprKind :: Path ( qpath) )
22112209 }
22122210
22132211 /// `<LangItem>::name`
0 commit comments