Auto merge of #76580 - rokob:iss76011, r=estebank

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.
This commit is contained in:
bors 2021-01-12 02:56:51 +00:00
commit 467f5e99a5
5 changed files with 34 additions and 17 deletions

View file

@ -1599,10 +1599,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()?;
@ -1619,6 +1615,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)),