What it does
Checks for needless bit mask when casting from a larger integer to a smaller integer to extract the trailing part of the integer. When casting casting from a larger integer to a smaller integer, the excess part is truncated, so bit mask is unnecessary.1
Advantage
Simplify code.
Drawbacks
No response
Example
fn split_half(n: u16) -> (u8, u8) {
(((n >> 8) & 0xff) as u8, (n & 0xff) as u8)
}
Could be written as:
fn split_half(n: u16) -> (u8, u8) {
((n >> 8) as u8, n as u8)
}
Comparison with existing lints
No response
Additional Context
No response