derive(Pod) generates code that triggers warn-by-default clippy::identity_op
Closed this issue · 2 comments
yanchith commented
Hi! Thanks for bytemuck ❤️ It is a pleasure to work with (compared to my previous unsafe versions of bytes_of
and from_bytes
).
When switching to it, I managed to trigger https://rust-lang.github.io/rust-clippy/master/index.html#identity_op in the code generated by the derives.
(run clippy
on tthe play pen)
The culprit seems to be this generated code, emitted as a static check before the unsafe impl is emitted:
const _: fn() =
||
{
struct TypeWithoutPadding([u8; 0 + ::core::mem::size_of::<f32>() +
::core::mem::size_of::<f32>()]);
let _ = ::core::mem::transmute::<Vec2, TypeWithoutPadding>;
};
Seems to be trivially fixable by checking the number of fields beforehand in https://github.com/Lokathor/bytemuck/blob/main/derive/src/traits.rs#L209
I can submit a fix, if you desired.
Lokathor commented
uh, sure if you wanna fix it up.
yanchith commented
This OCD is going to be the end of me one day.