Skip to content

Add expectation for { when parsing lone coroutine qualifiers #142362

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Jun 12, 2025

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Jun 11, 2025

Fixes #80931

@rustbot
Copy link
Collaborator

rustbot commented Jun 11, 2025

r? @oli-obk

rustbot has assigned @oli-obk.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 11, 2025
Comment on lines 1522 to -1538
// `Span::at_least_rust_2018()` is somewhat expensive; don't get it repeatedly.
let at_async = this.check_keyword(exp!(Async));
// check for `gen {}` and `gen move {}`
// or `async gen {}` and `async gen move {}`
// FIXME: (async) gen closures aren't yet parsed.
// FIXME(gen_blocks): Parse `gen async` and suggest swap
if this.token_uninterpolated_span().at_least_rust_2024()
// check for `gen {}` and `gen move {}`
// or `async gen {}` and `async gen move {}`
&& (this.is_gen_block(kw::Gen, 0)
|| (this.check_keyword(exp!(Async)) && this.is_gen_block(kw::Gen, 1)))
&& this.is_gen_block(kw::Gen, at_async as usize)
{
// FIXME: (async) gen closures aren't yet parsed.
this.parse_gen_block()
} else if this.check_keyword(exp!(Async)) {
// FIXME(gen_blocks): Parse `gen async` and suggest swap
if this.is_gen_block(kw::Async, 0) {
// Check for `async {` and `async move {`,
this.parse_gen_block()
} else {
this.parse_expr_closure()
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shuffled this around while looking through the call path as I found the {async} gen condition a bit heavy on the eyes. Happy to undo this

@rust-log-analyzer

This comment has been minimized.

@Veykril Veykril force-pushed the push-rzmrsswqourz branch from 36b11cf to ef92bb9 Compare June 11, 2025 13:34
&& coroutine_kind.is_some()
{
// couroutine closures and generators can have the same qualifiers, so we might end up
// in here if there is a missing `|` but also no `{`. Adjust the expectations in that case.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... this feels like sth that we'd regularly hit elsewhere, too, because is_gen_block and similar functions won't put their things in the expectation list. Unsure how to resolve that, so what you wrote is ok, but it does feel a bit like papering over a more common issue

Copy link
Member Author

@Veykril Veykril Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was feeling the same about this actually, but I couldn't figure out a solution for this either for the time being. We would need to start consuming the qualifier list before dispatching into the actual coroutine / generator parsing routines I think given we can't build expectations for lookaheads.

@Veykril Veykril force-pushed the push-rzmrsswqourz branch from ef92bb9 to edc405d Compare June 11, 2025 15:12
@Veykril
Copy link
Member Author

Veykril commented Jun 11, 2025

@bors r=oli-obk

@bors
Copy link
Collaborator

bors commented Jun 11, 2025

📌 Commit edc405d has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 11, 2025
bors added a commit that referenced this pull request Jun 11, 2025
Rollup of 9 pull requests

Successful merges:

 - #142305 (Remove unneeded `check_id` calls as they are already called in `visit_id` in `EarlyContextAndPass` type)
 - #142314 (remove ice group pings from `triagebot.toml`)
 - #142343 (remove myself from the project)
 - #142346 (Add tracing import to execution context)
 - #142356 (Fix enter_trace_span!() using wrong $crate paths)
 - #142362 (Add expectation for `{` when parsing lone coroutine qualifiers)
 - #142364 (Do not warn on `rust.incremental` when using download CI rustc)
 - #142369 (Improve some attribute docs and rename groups)
 - #142374 (Fix missing newline trim in bootstrap)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit e78b619 into rust-lang:master Jun 12, 2025
10 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 12, 2025
rust-timer added a commit that referenced this pull request Jun 12, 2025
Rollup merge of #142362 - Veykril:push-rzmrsswqourz, r=oli-obk

Add expectation for `{` when parsing lone coroutine qualifiers

Fixes #80931
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mention expectation of { for parse error immediately after async in expressions
5 participants