@@ -479,6 +479,7 @@ export rust_common_flags := --edition=2021 \
-Wclippy::all \
-Wclippy::as_ptr_cast_mut \
-Wclippy::as_underscore \
+ -Wclippy::cast_lossless \
-Wclippy::ignored_unit_patterns \
-Wclippy::mut_mut \
-Wclippy::needless_bitwise_bool \
@@ -305,15 +305,15 @@ fn get_next_13b(data: &[u8], offset: usize) -> Option<(u16, usize)> {
// `b` is 20 at max (`bit_off` <= 7 and `size` <= 13).
let b = (bit_off + size) as u16;
- let first_byte = (data[byte_off] << bit_off >> bit_off) as u16;
+ let first_byte = u16::from(data[byte_off] << bit_off >> bit_off);
let number = match b {
0..=8 => first_byte >> (8 - b),
- 9..=16 => (first_byte << (b - 8)) + (data[byte_off + 1] >> (16 - b)) as u16,
+ 9..=16 => (first_byte << (b - 8)) + u16::from(data[byte_off + 1] >> (16 - b)),
_ => {
(first_byte << (b - 8))
- + ((data[byte_off + 1] as u16) << (b - 16))
- + (data[byte_off + 2] >> (24 - b)) as u16
+ + u16::from(data[byte_off + 1] << (b - 16))
+ + u16::from(data[byte_off + 2] >> (24 - b))
}
};
Some((number, size))
@@ -414,7 +414,7 @@ fn next(&mut self) -> Option<Self::Item> {
match self.segment {
Segment::Binary(data) => {
if self.offset < data.len() {
- let byte = data[self.offset] as u16;
+ let byte = data[self.offset].into();
self.offset += 1;
Some((byte, 8))
} else {
@@ -25,6 +25,7 @@
)]
#[allow(dead_code)]
+#[allow(clippy::cast_lossless)]
#[allow(clippy::ptr_as_ptr)]
#[allow(clippy::undocumented_unsafe_blocks)]
mod bindings_raw {
@@ -142,7 +142,7 @@ pub fn is_autoneg_enabled(&self) -> bool {
// SAFETY: The struct invariant ensures that we may access
// this field without additional synchronization.
let bit_field = unsafe { &(*self.0.get())._bitfield_1 };
- bit_field.get(13, 1) == bindings::AUTONEG_ENABLE as u64
+ bit_field.get(13, 1) == bindings::AUTONEG_ENABLE.into()
}
/// Gets the current auto-negotiation state.
@@ -426,7 +426,7 @@ impl<T: Driver> Adapter<T> {
// where we hold `phy_device->lock`, so the accessors on
// `Device` are okay to call.
let dev = unsafe { Device::from_raw(phydev) };
- T::match_phy_device(dev) as i32
+ T::match_phy_device(dev).into()
}
/// # Safety
@@ -14,6 +14,7 @@
#![cfg_attr(test, allow(unsafe_op_in_unsafe_fn))]
#![allow(
clippy::all,
+ clippy::cast_lossless,
clippy::ptr_as_ptr,
clippy::undocumented_unsafe_blocks,
dead_code,