about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorAndy Weiss <dragonbear@google.com>2020-09-09 15:16:34 -0700
committerAndy Weiss <dragonbear@google.com>2020-09-22 13:22:10 -0700
commit5b475a46181cc4e8bfe2ac64f3724a5c485d6c5c (patch)
treec14392e4936b7f78d308ecde758fa0a9b0ced8d1 /compiler/rustc_parse/src/parser
parent25b2f4861222d6507598149f576e7d25dc308c8c (diff)
downloadrust-5b475a46181cc4e8bfe2ac64f3724a5c485d6c5c.tar.gz
rust-5b475a46181cc4e8bfe2ac64f3724a5c485d6c5c.zip
Suggest async {} for async || {}
Fixes #76011

This adds support for adding help diagnostics to the feature gating checks and
then uses it for the async_closure gate to add the extra bit of help
information as described in the issue.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/expr.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index 69d13b5cf53..368c0d4c9bc 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -1554,10 +1554,6 @@ impl<'a> Parser<'a> {
         } else {
             Async::No
         };
-        if let Async::Yes { span, .. } = asyncness {
-            // Feature-gate `async ||` closures.
-            self.sess.gated_spans.gate(sym::async_closure, span);
-        }
 
         let capture_clause = self.parse_capture_clause();
         let decl = self.parse_fn_block_decl()?;
@@ -1574,6 +1570,11 @@ impl<'a> Parser<'a> {
             }
         };
 
+        if let Async::Yes { span, .. } = asyncness {
+            // Feature-gate `async ||` closures.
+            self.sess.gated_spans.gate(sym::async_closure, span);
+        }
+
         Ok(self.mk_expr(
             lo.to(body.span),
             ExprKind::Closure(capture_clause, asyncness, movability, decl, body, lo.to(decl_hi)),