Skip to content

Resynthesize foo<bar>( and foo<bar>:: in check_no_chained_comparison #144884

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xizheyin
Copy link
Contributor

@xizheyin xizheyin commented Aug 4, 2025

This PR addresses a FIXME in parser/diagnostics.rs.

When detecting mistyped turbofish syntax (e.g., foo<bar>() instead of foo::<bar>()), the parser would always generate an ExprKind::Err placeholder without validating the expressions & attempting recovery.

The parser now checks that both sides of the binary operation are actually path expressions before proceeding and reconstructs the intended expression when it's safe to do so.

PathSep Branch (Type<Generic>::method() patterns)

For expressions like Vec<i32>::new():
It V=validates that both sides of the comparison are path expressions, and reconstructs the corrected path prefix (Vec::<i32>). And then, it merges the corrected path with the parsed suffix (new()). Finally, it return corrected expression Vec::<i32>::new().

OpenParen Branch (func<arg>() patterns)

For expressions like my_func<T>(). It validates path expressions, and Reconstructs the complete function call with proper turbofish syntax.

r? @estebank

@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 Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants