Open kriswuollett opened 1 month ago
Hi @kriswuollett, I tried to add a test to our suite so we could catch any regressions but I wasn't able to reproduce it: https://github.com/rust-lang/rust-bindgen/pull/3034.
Check the expectation file specifically where the derive
attributes are always generated before the other custom attributes. I disabled formatting to be sure it wasn't interfering with the output.
I also checked the source code and here's the relevant section. The derive
attributes are always pushed before the custom attributes.
The interface and/or implementation of
bindgen::callbacks::ParseCallbacks
may need some changes to address a compile warning that may become an error in the future, see https://github.com/rust-lang/rust/issues/79202. I'm guessing that the very least derives need to appear before other attributes?I wish I remember what library it was, but I believe I already encountered a derive macro in the past that was very sensitive to order of everything and needed to be the very first one listed as well otherwise it would cause a compile error. If I come across it again, I'll be sure to update this issue.
Details
From a header file with a type like:
Using the
item_name
,add_derives
,add_attributes
, andenum_variant_name
parse callbacks:Which causes a warning for derive helper being used before it is introduced, rust-lang/rust#79202:
An example project is at https://github.com/kriswuollett/example-bindgen-derive-ordering/tree/0130dcd8fa3f8d0820ed53c711375152faa0cec2.