-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Suggest async {} for async || {} #76580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
r? @estebank |
Can we add a test? It should live somewhere in |
debug!("gate_feature(feature = {:?}, span = {:?}); has? {}", name, span, has_feature); | ||
if !has_feature && !span.allows_unstable($name) { | ||
feature_err_issue(&visitor.sess.parse_sess, name, span, GateIssue::Language, explain) | ||
.span_help(span, help) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we have a single span, I think this should be a bare help
call (without a span) so the output isn't too verbose/redundant. I would not close #76011, as that is asking for a structured suggestion, which we might be able to provide in the future (but this current change is a great mitigation).
Fixes rust-lang#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.
I updated the src/test/ui/async-await/feature-async-closure UI test. I also made a change to compiler/rustc_parse/src/parser/expr.rs because otherwise this help would show up in this test src/test/ui/parser/block-no-opening-brace. I can backout that change if you want and instead have this help show up in that case as well. But looking at that example, it didn't seem right to me that this code:
would produce an error about async closures being unstable. You don't know that this is trying to be a closure, it could very well have been an async block which is not unstable. The help message I am adding makes this part even more confusing because it suggests removing the || and replacing it with a { but there is no ||. I think moving the feature gate until after the parsing of the rest of the closure has no semantic impact but makes more sense as you shouldn't assume you have a closure if you don't have |, or ||, or {. |
ping @estebank |
ping @estebank - is there a better reviewer for this? |
I think estebank is catching up on reviews now. |
@bors r+ Noticed the following output
should also include |
📌 Commit 5b475a4 has been approved by |
☀️ Test successful - checks-actions |
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.