summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src
diff options
context:
space:
mode:
authorLukas Markeffsky <@>2022-09-12 16:54:25 +0200
committerLukas Markeffsky <@>2022-09-12 16:54:25 +0200
commit2b7fb8d9418dbf98e6ee8ed406f830b4fcbea55f (patch)
tree35f3e3a31dca920ce3ee87779a1ddac72fa72268 /compiler/rustc_ast_lowering/src
parent56e7678ca97e9740f7d09206f767d5bb676917f7 (diff)
downloadrust-2b7fb8d9418dbf98e6ee8ed406f830b4fcbea55f.tar.gz
rust-2b7fb8d9418dbf98e6ee8ed406f830b4fcbea55f.zip
Impove diagnostic for .await-ing non-futures
Diffstat (limited to 'compiler/rustc_ast_lowering/src')
-rw-r--r--compiler/rustc_ast_lowering/src/expr.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs
index f929549d704..cd03e3fb457 100644
--- a/compiler/rustc_ast_lowering/src/expr.rs
+++ b/compiler/rustc_ast_lowering/src/expr.rs
@@ -146,13 +146,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
                         |this| this.with_new_scopes(|this| this.lower_block_expr(block)),
                     ),
                 ExprKind::Await(ref expr) => {
-                    let span = if expr.span.hi() < e.span.hi() {
-                        expr.span.shrink_to_hi().with_hi(e.span.hi())
+                    let dot_await_span = if expr.span.hi() < e.span.hi() {
+                        let span_with_whitespace = self
+                            .tcx
+                            .sess
+                            .source_map()
+                            .span_extend_while(expr.span, char::is_whitespace)
+                            .unwrap_or(expr.span);
+                        span_with_whitespace.shrink_to_hi().with_hi(e.span.hi())
                     } else {
                         // this is a recovered `await expr`
                         e.span
                     };
-                    self.lower_expr_await(span, expr)
+                    self.lower_expr_await(dot_await_span, expr)
                 }
                 ExprKind::Closure(
                     ref binder,