You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bitwise negation might lead to hard-to-spot errors in case it is confused with a boolean negation.
Example code
let seq_id:u32;if !seq_id > last_seq_id {/* deal with non-monotonic ids */}
Note that the code above is wrong and the intended code is
let seq_id:u32;if !(seq_id > last_seq_id){/* deal with non-monotonic ids */}
Notes
While this lint is very specific to if scenario above, we would be happy with a simple "no bitwise negation" lint as our codebase does not contain much of bit-twiddling.
The text was updated successfully, but these errors were encountered:
Marker should already be capable to create such a lint. I would suggest waiting until v0.3.0, which will be released at the start of next month, since there will be several breaking changes in that one. Then we could implement this. :D
I feel like this could also be a good lint for Clippy, as it seems to be generally applicable. It surprised me that if !seq_id > last_seq_id would negate the bits o.O
Lint explanation
Bitwise negation might lead to hard-to-spot errors in case it is confused with a boolean negation.
Example code
Note that the code above is wrong and the intended code is
Notes
While this lint is very specific to
if
scenario above, we would be happy with a simple "no bitwise negation" lint as our codebase does not contain much of bit-twiddling.The text was updated successfully, but these errors were encountered: