-
Notifications
You must be signed in to change notification settings - Fork 19
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
Warnings for clippy::unnecessary_cast
for default values
#60
Comments
Ah interesting. The cast is usually only necessary if the bitfield type differs from the struct field type. |
Yes, the strange thing is that explicitly casting does remove the warning for some data structures, but not from others... This gives the warning: #[bitfield(u16)]
#[derive(PartialEq, Eq)]
pub struct HardwareVersion {
#[bits(4, access=RO)]
pub hardware_version: u8,
#[bits(12, default=0_u16)]
__: u16,
} While this does not: #[bitfield(u16)]
#[derive(PartialEq, Eq)]
pub struct CalibrationDataChars {
#[bits(10, access=RO)]
pub calibration_data_chars: u16,
#[bits(6, default=0_u8)]
__: u8,
} And just for fun, this gives the warning (but specifically for u16, not u8 as the empty bits should be): #[bitfield(u16)]
#[derive(PartialEq, Eq)]
pub struct CalibrationDataChars {
#[bits(10, access=RO)]
pub calibration_data_chars: u16,
#[bits(6, default=0)]
__: u8,
} I'm guessing this happens due to some internal way this structure is represented. The fact that the first data structure is a u16 bitfield, and the empty bits are also u16, while the second structure is a u16, and the empty bits are u8, is also likely related somehow. |
Ok I'll look into this :) |
Fixed in 0.9.4 and 0.10.1 |
Thank you for this great package! I've been using it with success, but it generates some warnings for
clippy::unnecessary_cast
, e.g.The text was updated successfully, but these errors were encountered: