diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-10-26 03:09:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-26 03:09:06 +0100 |
| commit | 083a5cd9a2cb087e9acd7c9e80e277883f7003b3 (patch) | |
| tree | 1d6b485d650276f49b81948719e3f499d6ba83a2 /compiler/rustc_parse/src | |
| parent | 9e907d420e44cd91bf0a5ee421be26f537261a22 (diff) | |
| parent | f5d7443a6bd90b78e61b9c47e5032b5e1be1e49f (diff) | |
| download | rust-083a5cd9a2cb087e9acd7c9e80e277883f7003b3.tar.gz rust-083a5cd9a2cb087e9acd7c9e80e277883f7003b3.zip | |
Rollup merge of #78214 - estebank:match-semicolon, r=oli-obk
Tweak match arm semicolon removal suggestion to account for futures * Tweak and extend "use `.await`" suggestions * Suggest removal of semicolon on prior match arm * Account for `impl Future` when suggesting semicolon removal * Silence some errors when encountering `await foo()?` as can't be certain what the intent was *Thanks to https://twitter.com/a_hoverbear/status/1318960787105353728 for pointing this out!*
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/parser/diagnostics.rs | 8 |
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) } |
