Consider alignment contribution from bitfields by nbdd0121 · Pull Request #2388 · rust-lang/rust-bindgen (original) (raw)

Partial fix to https://lore.kernel.org/rust-for-linux/Y8Ax%2FI5qOcVDZljG@zn.tnic/ (not a full fix, because it short below is replaced with a int then the code still fails to compile)

Currently binding for code like this wouldn't compile:

struct outer { struct { short a: 16; short b: 16; }; } attribute((packed));

because bindgen sticks an extra #[repr(align(2))] on the inner struct.

This extra alignment is not necessary and can be removed. The removed NB line in this PR is no longer relevant because of the addition _bitfield_align field generated starting in #1950.

cc @emilio @ojeda