Make async removal span more resilient to macro expansions
This commit is contained in:
parent
d4200276f2
commit
6d6c904431
7 changed files with 68 additions and 24 deletions
|
@ -108,7 +108,7 @@ pub struct BaseExpressionDoubleDot {
|
|||
pub struct AwaitOnlyInAsyncFnAndBlocks {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
pub dot_await_span: Span,
|
||||
pub await_kw_span: Span,
|
||||
#[label(ast_lowering_this_not_async)]
|
||||
pub item_span: Option<Span>,
|
||||
}
|
||||
|
|
|
@ -185,15 +185,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
hir::AsyncGeneratorKind::Block,
|
||||
|this| this.with_new_scopes(|this| this.lower_block_expr(block)),
|
||||
),
|
||||
ExprKind::Await(expr, await_kw_span) => {
|
||||
let await_kw_span = if expr.span.hi() < await_kw_span.hi() {
|
||||
*await_kw_span
|
||||
} else {
|
||||
// this is a recovered `await expr`
|
||||
e.span
|
||||
};
|
||||
self.lower_expr_await(await_kw_span, expr)
|
||||
}
|
||||
ExprKind::Await(expr, await_kw_span) => self.lower_expr_await(*await_kw_span, expr),
|
||||
ExprKind::Closure(box Closure {
|
||||
binder,
|
||||
capture_clause,
|
||||
|
@ -710,7 +702,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
Some(hir::GeneratorKind::Async(_)) => {}
|
||||
Some(hir::GeneratorKind::Gen) | None => {
|
||||
self.tcx.sess.emit_err(AwaitOnlyInAsyncFnAndBlocks {
|
||||
dot_await_span: await_kw_span,
|
||||
await_kw_span,
|
||||
item_span: self.current_item,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue