meithecatte/enumflags2

Fails to compile with #![deny(trivial_numeric_casts)]

Closed this issue · 3 comments

This might be intentional (or unavoidable) but I found that when used the lint #![deny(trivial_numeric_casts)] the example from the readme fails to compile. And for some reason not even adding #[allow(trivial_numeric_casts)] for only the specific enum would change anything. I could remove the #[repr(u8)] but then the type was defaulted to usize which I did not want.

#[derive(BitFlags, Copy, Clone, Debug, PartialEq)]
#[repr(u8)]
enum Test {
    A = 0b0001,
    B = 0b0010,
    C = 0b0100,
    D = 0b1000,
}
trivial numeric cast: `u8` as `u8`

help: cast can be replaced by coercion; this might require a temporary variable rustc(trivial_numeric_casts)

Removing BitFlags from the derive makes it compile again.

Thanks for the report! I've pushed a commit that seems to fix the issue. Could you try temporarily switching your dependency in Cargo.toml to point to this repository, and check if it also fixes it for you?

enumflags2 = { git = "https://github.com/NieDzejkob/enumflags2" }

I have tested it and now it works nicely. Well done!

Thanks! I published the change as 0.6.3.