-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix ArgWithDefault comments handling #5204
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Current dependencies on/for this PR: This comment was auto-generated by Graphite. |
7657211
to
84dd7db
Compare
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinux
Windows
|
konstin
approved these changes
Jun 20, 2023
Is this upstream or downstream of the other RustPython upgrade PRs I have up? |
Depends on who merges first ;) The PR is astral-sh/RustPython-Parser#13 |
Looks like I win |
84dd7db
to
bc67cd0
Compare
bc67cd0
to
511b47f
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR fixes a few issues with formatting arguments that were introduced when upgrading to the latest RustPython parser (#5192).
ArgWithDefault
Fix ArgWithDefault TextRange RustPython-Parser#13visit_arg_with_default
function in theCommentsVisitor
ArgWithDefault
andArg
resolved to the same comments. My understanding of the issue is that Rust re-orders the fields inArgWithDefault
so thatArg
becomes its first field. The result is that both theArgWithDefault
andArg
are stored at the same memory offset (but they don't end at the same memory offset). I wonder if we have the same problem withRefEquality
(CC: @charliermarsh). The way I fixed the issue is by including the node kind in the equality check. This is safe because we only have this problem for nodes that don't box their children (which is why `BinaryExpression isn't affected by it) and recursive types need boxing (the only way that the parent and child have the same kind).Test Plan
I added a new test for formatting arguments.