-
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
Spot wrong usage of bitwise and operator #1594
Comments
/me disappointed |
In my opinion there's a small number of Clippy lints that should be Rustc errors (or warnings). |
What I meant is I did not expect |
Actually there are valid use cases for this, because the regular bool ops short circuit but in that case the lint can be disabled, since these cases are rare. |
Perhaps this could only apply to constant operations and functions that are known to have no side effects? That way those cases don't require disabling the lint. Or better, we split into two lints, one that does just the ones that are known to have no side effects, and one that covers the ones that might have side effects. That way people can disable the ones for side effects while still having the benefit of checking cases like these. |
@oli-obk I know but this is rare enough that I would have expected to have to bind the expressions (and of course add a comment) rather that be allowed to use |
Wrong button (morning 😅). |
It's a common mistake, so I've sent a "bug report" to GitHub about the design of those two buttons. |
Add `needless_bitwise_bool` lint fixes #6827 fixes #1594 changelog: Add ``[`needless_bitwise_bool`]`` lint Creates a new `bitwise_bool` lint to convert `x & y` to `x && y` when both `x` and `y` are booleans. I also had to adjust thh `needless_bool` lint slightly, and fix a couple failing dogfood tests. I made it a correctness lint as per flip1995's comment [here](#3385 (comment)), from a previous WIP attempt at this lint.
Add `needless_bitwise_bool` lint fixes #6827 fixes #1594 changelog: Add ``[`needless_bitwise_bool`]`` lint Creates a new `bitwise_bool` lint to convert `x & y` to `x && y` when both `x` and `y` are booleans. I also had to adjust thh `needless_bool` lint slightly, and fix a couple failing dogfood tests. I made it a correctness lint as per flip1995's comment [here](#3385 (comment)), from a previous WIP attempt at this lint.
I'd like Clippy to warn in this expression suggesting that this is probably an error, and that the programmer perhaps meant to use "&&" instead:
The text was updated successfully, but these errors were encountered: