diff options
author | uk <50893351+unterkontrolle@users.noreply.github.com> | 2019-06-11 11:49:48 -0300 |
---|---|---|
committer | uk <50893351+unterkontrolle@users.noreply.github.com> | 2019-06-11 11:49:48 -0300 |
commit | b2c478f9ccb971f350e364d16a45cdd128dca3a8 (patch) | |
tree | 6787766df27f953caced6adac55ceea090843037 | |
parent | ac78e077c70586d66d19aee21ecececc16cb90f8 (diff) |
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
-rw-r--r-- | src/codegen/mod.rs | 4 | ||||
-rw-r--r-- | src/features.rs | 2 |
2 files changed, 5 insertions, 1 deletions
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; } ); |