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

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

Conversation

xizheyin
Copy link
Member

@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

…ison`

Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
@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
@bors
Copy link
Collaborator

bors commented Aug 23, 2025

☔ The latest upstream changes (presumably #145773) made this pull request unmergeable. Please resolve the merge conflicts.

@xizheyin xizheyin marked this pull request as draft August 23, 2025 10:28
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 23, 2025
@xizheyin
Copy link
Member Author

This pr seems a bit big, so split it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

4 participants