about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-10-22 10:51:49 -0700
committerEsteban Küber <esteban@kuber.com.ar>2020-10-23 08:06:41 -0700
commit3a0227bc49397879b240373d84b2a80e05569724 (patch)
tree97edcf80485fabf8aa3d43c17b6cf18f6c89d3be /compiler/rustc_parse/src
parent62ba365195e37b0508dc35f73b55243cb1aef7f3 (diff)
downloadrust-3a0227bc49397879b240373d84b2a80e05569724.tar.gz
rust-3a0227bc49397879b240373d84b2a80e05569724.zip
Silence unnecessary `await foo?` knock-down error
Diffstat (limited to 'compiler/rustc_parse/src')
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs
index 1ea01d95a13..39e1256a578 100644
--- a/compiler/rustc_parse/src/parser/diagnostics.rs
+++ b/compiler/rustc_parse/src/parser/diagnostics.rs
@@ -1207,7 +1207,13 @@ impl<'a> Parser<'a> {
             self.recover_await_prefix(await_sp)?
         };
         let sp = self.error_on_incorrect_await(lo, hi, &expr, is_question);
-        let expr = self.mk_expr(lo.to(sp), ExprKind::Await(expr), attrs);
+        let kind = match expr.kind {
+            // Avoid knock-down errors as we don't know whether to interpret this as `foo().await?`
+            // or `foo()?.await` (the very reason we went with postfix syntax 😅).
+            ExprKind::Try(_) => ExprKind::Err,
+            _ => ExprKind::Await(expr),
+        };
+        let expr = self.mk_expr(lo.to(sp), kind, attrs);
         self.maybe_recover_from_bad_qpath(expr, true)
     }