diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-05-01 01:09:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-01 01:09:47 +0200 |
| commit | 1b262b8b5660bc70530f647822b477a8d56e1f4e (patch) | |
| tree | 41299c6d6c037d6b6addf13a984f9220fba45cd0 /compiler/rustc_ast | |
| parent | 9ecda8de85ce893cc3fc748ab06be0b8250147a7 (diff) | |
| parent | 6d6c90443182e18fb23c08cd2d97dae701d7b453 (diff) | |
| download | rust-1b262b8b5660bc70530f647822b477a8d56e1f4e.tar.gz rust-1b262b8b5660bc70530f647822b477a8d56e1f4e.zip | |
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.
Diffstat (limited to 'compiler/rustc_ast')
| -rw-r--r-- | compiler/rustc_ast/src/ast.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/mut_visit.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/util/parser.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/visit.rs | 2 |
4 files changed, 8 insertions, 5 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 3ed342ce48b..ea04ba4f66e 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -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>), diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 99f1f4bd968..68a4d522993 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -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); diff --git a/compiler/rustc_ast/src/util/parser.rs b/compiler/rustc_ast/src/util/parser.rs index 24b4bd8623f..64ae904513c 100644 --- a/compiler/rustc_ast/src/util/parser.rs +++ b/compiler/rustc_ast/src/util/parser.rs @@ -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, _) diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index 8a6b5d5c905..1526ffa0b03 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -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); |
