Skip to content
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

Make sure we consume a generic arg when checking mistyped turbofish #124930

Merged
merged 1 commit into from May 11, 2024

Conversation

compiler-errors
Copy link
Member

When recovering un-turbofish-ed args in expr position (e.g. let x = a<T, U>(); in check_mistyped_turbofish_with_multiple_type_params, we used parse_seq_to_before_end to parse the fake generic args; however, it used parse_generic_arg which optionally parses a generic arg. If it doesn't end up parsing an arg, it returns Ok(None) and consumes no tokens. If we don't find a delimiter after this (,), we try parsing another element. In this case, we just infinitely loop looking for a subsequent element.

We can fix this by making sure that we either parse a generic arg or error in parse_seq_to_before_end's callback.

Fixes #124897

@rustbot
Copy link
Collaborator

rustbot commented May 9, 2024

r? @petrochenkov

rustbot has assigned @petrochenkov.
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 May 9, 2024
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented May 10, 2024

📌 Commit dbdef68 has been approved by petrochenkov

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 May 10, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request May 11, 2024
Rollup of 5 pull requests

Successful merges:

 - rust-lang#124233 (Add `-lmingwex` second time in `mingw_libs`)
 - rust-lang#124318 (ignore generics args in attribute paths)
 - rust-lang#124899 (bootstrap: add comments for the automatic dry run)
 - rust-lang#124904 (reachable computation: extend explanation of what this does, and why)
 - rust-lang#124930 (Make sure we consume a generic arg when checking mistyped turbofish)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit e7bb090 into rust-lang:master May 11, 2024
6 checks passed
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 11, 2024
Rollup merge of rust-lang#124930 - compiler-errors:consume-arg, r=petrochenkov

Make sure we consume a generic arg when checking mistyped turbofish

When recovering un-turbofish-ed args in expr position (e.g. `let x = a<T, U>();` in `check_mistyped_turbofish_with_multiple_type_params`, we used `parse_seq_to_before_end` to parse the fake generic args; however, it used `parse_generic_arg` which *optionally* parses a generic arg. If it doesn't end up parsing an arg, it returns `Ok(None)` and consumes no tokens. If we don't find a delimiter after this (`,`), we try parsing *another* element. In this case, we just infinitely loop looking for a subsequent element.

We can fix this by making sure that we either parse a generic arg or error in `parse_seq_to_before_end`'s callback.

Fixes rust-lang#124897
@rustbot rustbot added this to the 1.80.0 milestone May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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.

hang in parser::diagnostics::expected_one_of_not_found()
4 participants