From b2c478f9ccb971f350e364d16a45cdd128dca3a8 Mon Sep 17 00:00:00 2001 From: uk <50893351+unterkontrolle@users.noreply.github.com> Date: Tue, 11 Jun 2019 11:49:48 -0300 Subject: Add rust target configuration for feature #1554 Will panic if the feature is being used outside nightly. See https://github.com/rust-lang/rust-bindgen/pull/1575#discussion_r292231027 --- src/codegen/mod.rs | 4 +++- src/features.rs | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index aa920c9b..2863387f 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -2580,8 +2580,10 @@ impl CodeGenerator for Enum { match variation { EnumVariation::Rust { non_exhaustive: nh } => { attrs.push(attributes::repr(repr_name)); - if nh { + if nh && ctx.options().rust_features().non_exhaustive { attrs.push(attributes::non_exhaustive()); + } else if nh && !ctx.options().rust_features().non_exhaustive { + panic!("The rust target you're using doesn't seem to support non_exhaustive enums"); } }, EnumVariation::Bitfield => { diff --git a/src/features.rs b/src/features.rs index 05f5dc42..4dc526ec 100644 --- a/src/features.rs +++ b/src/features.rs @@ -206,6 +206,8 @@ rust_feature_def!( Nightly { /// `thiscall` calling convention ([Tracking issue](https://github.com/rust-lang/rust/issues/42202)) => thiscall_abi; + /// `non_exhaustive` enums/structs ([Tracking issue](https://github.com/rust-lang/rust/issues/44109)) + => non_exhaustive; } ); -- cgit v1.2.3