From ce9250c6f11a982e73058ae8de792c13e05e3a9a Mon Sep 17 00:00:00 2001 From: Felix Solcher Date: Sun, 28 Sep 2025 14:40:18 +0200 Subject: [PATCH] Add undefined behaviour warning to `rustified_non_exhaustive_enum` --- bindgen/options/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bindgen/options/mod.rs b/bindgen/options/mod.rs index 767be03e35..debe16cd76 100644 --- a/bindgen/options/mod.rs +++ b/bindgen/options/mod.rs @@ -541,6 +541,11 @@ options! { /// /// This is similar to the [`Builder::rustified_enum`] style, but the `enum` is /// tagged with the `#[non_exhaustive]` attribute. + /// + /// **Use this with caution**, creating an instance of a Rust `enum` with an + /// invalid value will cause undefined behaviour, even if it's tagged with + /// `#[non_exhaustive]`. To avoid this, use the [`Builder::newtype_enum`] style + /// instead. pub fn rustified_non_exhaustive_enum>(mut self, arg: T) -> Builder { self.options.rustified_non_exhaustive_enums.insert(arg); self