Resynthesize foo<bar>(
and foo<bar>::
in check_no_chained_comparison
#144884
+187
−21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses a FIXME in
parser/diagnostics.rs
.When detecting mistyped turbofish syntax (e.g.,
foo<bar>()
instead offoo::<bar>()
), the parser would always generate anExprKind::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 expressionVec::<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