-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
bool_to_int_with_if
inverse case patch
#9476
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @xFrednet (or someone else) soon. Please see the contribution instructions for more information. |
let invert = if inverted { "!" } else { "" }; | ||
let need_parens = should_have_parentheses(check); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clippy has an helper struct that will already handle parenthesis for you, including when negating the expression: clippy_utils::sugg::Sugg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That fixed a bug in the lint, and in turn fixed a bug in clippy_utils::sugg::Sugg
, so thanks!
☔ The latest upstream changes (presumably #8518) made this pull request unmergeable. Please resolve the merge conflicts. |
I did! Thank you |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Enhances
bool_to_int_with_if
such that it can also catch an inverse bool int conversion scenario, and makes the right suggestion for converting to int with a prefixed negation operator.changelog: [
bool_to_int_with_if
]: Now correctly detects the inverse case,if bool { 0 } else { 1 }