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

auto-fix if_not_else #13411

Closed
Rudxain opened this issue Sep 18, 2024 · 4 comments · Fixed by #13809
Closed

auto-fix if_not_else #13411

Rudxain opened this issue Sep 18, 2024 · 4 comments · Fixed by #13809

Comments

@Rudxain
Copy link
Contributor

Rudxain commented Sep 18, 2024

Description

Note

I'm unsure if this is a bug-report or feature-request

cargo clippy --fix should swap the 2 blocks

Version

1.81.0

I'm sorry, I'm not using the device that has the tool-chain installed

Additional Labels

No response

@lukaslueg
Copy link
Contributor

@Rudxain, there is no content in your op

@Rudxain

This comment has been minimized.

@samueltardieu
Copy link
Contributor

@Rudxain Is it supposed to contain some code?

Image

@Rudxain
Copy link
Contributor Author

Rudxain commented Dec 1, 2024

What I meant is that the example given:

if !v.is_empty() {
    a()
} else {
    b()
}

(and anything of the same form) should be auto-fixable.

Trying to fix it manually is very error-prone for bigger blocks, and git diff doesn't help much either :(

github-merge-queue bot pushed a commit that referenced this issue Dec 24, 2024
fix #13411

The `if_not_else` lint can be fixed automatically, but the issue above
reports that there is no implementation to do so. Therefore, this PR
implements it.

----

changelog: [`if_not_else`]: make suggestions for modified code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants