Rollup merge of #125078 - linyihai:issue-124496, r=compiler-errors
fix: break inside async closure has incorrect span for enclosing closure Fixes #124496
This commit is contained in:
commit
c9a9d5cee7
4 changed files with 22 additions and 12 deletions
|
@ -1319,6 +1319,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
CoroutineKind::AsyncGen { .. } => hir::CoroutineDesugaring::AsyncGen,
|
||||
};
|
||||
let closure_id = coroutine_kind.closure_id();
|
||||
|
||||
let span = if let FnRetTy::Default(span) = decl.output
|
||||
&& matches!(coroutine_source, rustc_hir::CoroutineSource::Closure)
|
||||
{
|
||||
body_span.with_lo(span.lo())
|
||||
} else {
|
||||
body_span
|
||||
};
|
||||
let coroutine_expr = self.make_desugared_coroutine_expr(
|
||||
// The default capture mode here is by-ref. Later on during upvar analysis,
|
||||
// we will force the captured arguments to by-move, but for async closures,
|
||||
|
@ -1327,7 +1335,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
CaptureBy::Ref,
|
||||
closure_id,
|
||||
None,
|
||||
body_span,
|
||||
span,
|
||||
desugaring_kind,
|
||||
coroutine_source,
|
||||
mkbody,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue