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

fix: rewrite DeMorgan assist #15410

Merged
merged 2 commits into from Aug 15, 2023
Merged

Conversation

alibektas
Copy link
Member

@alibektas alibektas commented Aug 7, 2023

fixes #15239 , #15240 . This PR is a rewrite of the DeMorgan assist that essentially rids of all the string manipulation and modifies syntax trees to apply demorgan on a binary expr. The main reason for the rewrite is that I wanted to use Expr::needs_parens_in method to see if the expr on which the assist is applied would still need the parens it had once the parent expression's operator had equal precedence with that of the expression. I used .clone_(subtree|for_update) left and right and probably more than I should have, so I would also be happy to hear how I could have prevented redundant cloning.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 7, 2023
@alibektas alibektas changed the title internal : rewrite DeMorgan using syntax trees internal : rewrite DeMorgan assist Aug 7, 2023
@alibektas
Copy link
Member Author

Since there won't be any unwraps in apply_demorgan after this PR, we can also mark it as completed in #15398

@lnicola lnicola mentioned this pull request Aug 7, 2023
15 tasks
@Veykril
Copy link
Member

Veykril commented Aug 15, 2023

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 15, 2023

📌 Commit 17f3055 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Aug 15, 2023

⌛ Testing commit 17f3055 with merge 7ca45dc...

@bors
Copy link
Collaborator

bors commented Aug 15, 2023

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 7ca45dc to master...

@bors bors merged commit 7ca45dc into rust-lang:master Aug 15, 2023
10 checks passed
@lnicola lnicola changed the title internal : rewrite DeMorgan assist fix: rewrite DeMorgan assist Aug 15, 2023
@alibektas alibektas deleted the 15240/invalid-demorgan branch August 18, 2023 18:06
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Apply De Morgan's Law" does not round-trip properly
4 participants