Open
Description
openedon Jan 23, 2021
What it does
Consider this code snippet:
pub const fn to_4_be_nibles(op: u16) -> [u8; 4] {
[
(op & 0xF000 >> 12) as u8,
(op & 0x0F00 >> 8) as u8,
(op & 0x00F0 >> 4) as u8,
(op & 0x000F) as u8,
]
}
We'd realize that the code is wrong. >>
has stronger precedence than &
operator.
So we has to use ()
to group (op & 0F000)
and the like.
I'd like to have a lint about this.
Categories (optional)
- Kind: clippy::correctness
Drawbacks
None.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment