Supporting 2021-edition features · Issue #2998 · rust-lang/rust-bindgen (original) (raw)
While working on #2994 to add C-string literals like c"Hello"
- a feature only available in the 2021 edition, I realized that bindgen is still using 2018 edition everywhere. Moreover, bindgen has a concept of Rust versions (and which features were enabled in which version), but it has no notion of the edition - targeting 2018 syntax everywhere (essentially unaware the needed edition of the output code).
The CStr
support is behind a generate_cstr
flag, but that means users would have to either use the older byte array type [u8; #len]
if they are currently still on 2018 but have enabled the cstr feature, or they would have to bump their edition to 2021. This does not seem like too big of a deal - CStr is a relatively recent addition, long time after 2021 edition was added.
The bigger issue is overall trend - bindgen may need to generate different code depending on the target edition.