bool_to_int_with_if inverse case patch#9476
bool_to_int_with_if inverse case patch#9476bors merged 4 commits intorust-lang:masterfrom Xaeroxe:bool-to-int-inverted
bool_to_int_with_if inverse case patch#9476Conversation
|
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.
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.
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_ifsuch 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 }