1
Fork 0

Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naber

Tweak await span to not contain dot

Fixes a discrepancy between method calls and await expressions where the latter are desugared to have a span that *contains* the dot (i.e. `.await`) but method call identifiers don't contain the dot. This leads to weird suggestions suggestions in borrowck -- see linked issue.

Fixes #110761

This mostly touches a bunch of tests to tighten their `await` span.
This commit is contained in:
Matthias Krüger 2023-05-01 01:09:47 +02:00 committed by GitHub
commit 1b262b8b56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
113 changed files with 594 additions and 807 deletions

View file

@ -1430,8 +1430,8 @@ pub enum ExprKind {
/// The async block used to have a `NodeId`, which was removed in favor of
/// using the parent `NodeId` of the parent `Expr`.
Async(CaptureBy, P<Block>),
/// An await expression (`my_future.await`).
Await(P<Expr>),
/// An await expression (`my_future.await`). Span is of await keyword.
Await(P<Expr>, Span),
/// A try block (`try { ... }`).
TryBlock(P<Block>),

View file

@ -1415,7 +1415,10 @@ pub fn noop_visit_expr<T: MutVisitor>(
ExprKind::Async(_capture_by, body) => {
vis.visit_block(body);
}
ExprKind::Await(expr) => vis.visit_expr(expr),
ExprKind::Await(expr, await_kw_span) => {
vis.visit_expr(expr);
vis.visit_span(await_kw_span);
}
ExprKind::Assign(el, er, _) => {
vis.visit_expr(el);
vis.visit_expr(er);

View file

@ -388,7 +388,7 @@ pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool {
// X { y: 1 } + X { y: 2 }
contains_exterior_struct_lit(lhs) || contains_exterior_struct_lit(rhs)
}
ast::ExprKind::Await(x)
ast::ExprKind::Await(x, _)
| ast::ExprKind::Unary(_, x)
| ast::ExprKind::Cast(x, _)
| ast::ExprKind::Type(x, _)

View file

@ -864,7 +864,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
ExprKind::Async(_, body) => {
visitor.visit_block(body);
}
ExprKind::Await(expr) => visitor.visit_expr(expr),
ExprKind::Await(expr, _) => visitor.visit_expr(expr),
ExprKind::Assign(lhs, rhs, _) => {
visitor.visit_expr(lhs);
visitor.visit_expr(rhs);