Skip to content

Commit bef018e

Browse files
committed
Mark yield spans with desugaring
1 parent ead5e12 commit bef018e

File tree

1 file changed

+7
-6
lines changed
  • compiler/rustc_ast_lowering/src

1 file changed

+7
-6
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,12 +1721,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
17211721
// `yield $expr` is transformed into `task_context = yield async_gen_ready($expr)`.
17221722
// This ensures that we store our resumed `ResumeContext` correctly, and also that
17231723
// the apparent value of the `yield` expression is `()`.
1724+
let desugar_span = self.mark_span_with_reason(
1725+
DesugaringKind::Async,
1726+
span,
1727+
Some(Arc::clone(&self.allow_async_gen)),
1728+
);
17241729
let wrapped_yielded = self.expr_call_lang_item_fn(
1725-
self.mark_span_with_reason(
1726-
DesugaringKind::Async,
1727-
span,
1728-
Some(Arc::clone(&self.allow_async_gen)),
1729-
),
1730+
desugar_span,
17301731
hir::LangItem::AsyncGenReady,
17311732
std::slice::from_ref(yielded),
17321733
);
@@ -1738,7 +1739,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
17381739
unreachable!("use of `await` outside of an async context.");
17391740
};
17401741
let task_context_ident = Ident::with_dummy_span(sym::_task_context);
1741-
let lhs = self.expr_ident(span, task_context_ident, task_context_hid);
1742+
let lhs = self.expr_ident(desugar_span, task_context_ident, task_context_hid);
17421743

17431744
hir::ExprKind::Assign(lhs, yield_expr, self.lower_span(span))
17441745
} else {

0 commit comments

Comments
 (0)