Open isaacmorgan opened 2 weeks ago
I think using ManuallyDrop
is not a good workaround for (I assume) the same reason for the error in the first place: there's no (?) way to drop an unaligned dynamically sized type. In order to drop the value must be copied to an aligned location, but this can't be done because it's dynamically sized. Something like that.
cc @jsgf
Yeah I think DSTs and packed are intrinsically incompatible, even though the kind of structure you're using is certainly common in C headers.
I do think ManuallyDrop is the best compromise. A packed DST field with a non-trivial drop will just need very bespoke handling. OTOH if it has a trivial drop - as in this case - then ignoring the ManuallyDrop will still be the right result.
When I run bindgen with a packed struct containing a flexible array member I get a compilation error because the FAM uses drop.
I can edit the bindgen generated file to wrap
FAM
insideManuallyDrop
and it compiles successfully and appears to be working. Though I'm not sure if that approach is the right thing to do. Is there a way for bindgen to handle this itself, is there a better way than usingManuallyDrop
?test.h
build.rs
output error
bindings.rs output with ManuallyDrop added