Robbepop / modular-bitfield

Macro to generate bitfields for structs that allow for modular use of enums.
Apache License 2.0
155 stars 40 forks source link

Clippy warns about "the operation is ineffective" and unable to set `#[allow(...)]` #62

Open TheAifam5 opened 3 years ago

TheAifam5 commented 3 years ago

Adding repr to the struct results in a clippy warning:

the operation is ineffective. Consider reducing it to `mregion: u8`

Adding #[allow(clippy::identity_op)] on top of the struct does not disable the warning.

Example (straight from the test):

use modular_bitfield::prelude::*;

#[bitfield]
#[repr(u32)]
#[derive(Debug, PartialEq, Eq)]
struct TtResp {
    mregion: u8,
    sregion: u8, 
    mrvalid: bool,
    srvalid: bool,
    r: bool,
    rw: bool,
    nsr: bool,
    nsrw: bool,
    s: bool,
    irvalid: bool,
    iregion: u8,
}

Rust: 1.52.0-nightly (d6eaea1c8 2021-03-14) Clippy: 0.1.52 (d6eaea1c 2021-03-14) Crate Version: 0.11.2

MJDSys commented 2 years ago

As a workaround until the PR is merged, if you specify the number of bits to use for the struct the clippy warning is also removed. The above code would change to:

#[bitfield(bits = 32)]
#[repr(u32)]
struct ...