-
Notifications
You must be signed in to change notification settings - Fork 31
Warnings when compiling with packed_struct, crash with clippy #10
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
Comments
Compile warning: it'll be fixed with a generated attribute to ignore parenthesis warnings (#11). Regarding clippy, this seems like a clippy bug and not at all related to any bugs in this crate. For your last report, could you please post the structure from |
Nice, thank you ! I didn't see this PR. Sure, here is the struct: #[derive(Debug, Deserialize, PackedStruct)] // this is line 43
#[packed_struct(bit_numbering = "msb0")]
pub struct LEDDriverConfig {
#[packed_field(bits = "46..47")]
lodvth: Integer<u8, ::packed_bits::Bits2>,
#[packed_field(bits = "44..45")]
sel_td0: Integer<u8, ::packed_bits::Bits2>,
#[packed_field(bits = "43")]
sel_gdly: Integer<u8, ::packed_bits::Bits1>,
#[packed_field(bits = "42")]
xrefresh: Integer<u8, ::packed_bits::Bits1>,
#[packed_field(bits = "41")]
sel_gck_edge: Integer<u8, ::packed_bits::Bits1>,
#[packed_field(bits = "40")]
sel_pchg: Integer<u8, ::packed_bits::Bits1>,
#[packed_field(bits = "39")]
espwm: Integer<u8, ::packed_bits::Bits1>,
#[packed_field(bits = "38")]
lgse3: Integer<u8, ::packed_bits::Bits1>,
#[packed_field(bits = "37")]
sel_sck_edge: Integer<u8, ::packed_bits::Bits1>,
#[packed_field(bits = "34..36")]
lgse1: Integer<u8, ::packed_bits::Bits3>,
#[packed_field(bits = "25..33", endian = "msb")]
ccb: Integer<u16, ::packed_bits::Bits9>,
#[packed_field(bits = "16..24", endian = "msb")]
ccg: Integer<u16, ::packed_bits::Bits9>,
#[packed_field(bits = "7..15", endian = "msb")]
ccr: Integer<u16, ::packed_bits::Bits9>,
#[packed_field(bits = "4..6")]
bc: Integer<u8, ::packed_bits::Bits3>,
#[packed_field(bits = "3")]
poker_trans_mode: Integer<u8, ::packed_bits::Bits1>,
#[packed_field(bits = "0..2")]
lgse2: Integer<u8, ::packed_bits::Bits3>,
} To be able to use error_chain, I had to put the error_chain! code into a module: mod errors {
error_chain! {
foreign_links {
Toml(::toml::de::Error);
Io(::io::Error);
ParseInt(::std::num::ParseIntError);
Image(::image::ImageError);
}
}
} And the functions using this crate are like this one: fn run() -> Result<()> { I can provide some time if you need a minimal example code reproducing this issue or some help on this issue. |
The problem was that importing I'll close this issue once 0.2.1 is released with this fix. In the meantime, you can point your project directly to the Git repository and check for any other issues. |
Closing due to inactivity, and the reporting issue actually being an external project. 0.2.1 of this crate was released as well. |
Sorry, didn't found the time to change our code and test, but I'll suggest minor changes as soon as I can also. The issue with clippy seems to have been fixed too. Thank you for your work. |
Hello, I'm using your library for a student's project. Thank you for your work.
On any simple program implementing packed_struct, rustc is emitting the following warnings:
Moreover, clippy crashes when trying to lint the program. It shouldn't crash but it might unveil some flaws in the code of packed_struct.
For example, packed_struct prevents us from directly using error_chain! to handle errors, because of the following compile errors:
See also this issue on clippy: rust-lang/rust-clippy#2359
The text was updated successfully, but these errors were encountered: