diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/codegen/bitfield_unit.rs | 2 | ||||
-rw-r--r-- | src/codegen/mod.rs | 16 | ||||
-rw-r--r-- | src/features.rs | 7 |
3 files changed, 21 insertions, 4 deletions
diff --git a/src/codegen/bitfield_unit.rs b/src/codegen/bitfield_unit.rs index 5c7a09bd..caab2dc6 100755 --- a/src/codegen/bitfield_unit.rs +++ b/src/codegen/bitfield_unit.rs @@ -9,7 +9,7 @@ pub struct __BindgenBitfieldUnit<Storage, Align> impl<Storage, Align> __BindgenBitfieldUnit<Storage, Align> { #[inline] - pub fn new(storage: Storage) -> Self { + pub const fn new(storage: Storage) -> Self { Self { storage, align: [], diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index c3b86983..551c0bdb 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -410,7 +410,7 @@ impl CodeGenerator for Module { utils::prepend_objc_header(ctx, &mut *result); } if result.saw_bitfield_unit { - utils::prepend_bitfield_unit_type(&mut *result); + utils::prepend_bitfield_unit_type(ctx, &mut *result); } } }; @@ -3591,11 +3591,21 @@ mod utils { use ir::item::{Item, ItemCanonicalPath}; use ir::ty::TypeKind; use proc_macro2; + use std::borrow::Cow; use std::mem; use std::str::FromStr; - pub fn prepend_bitfield_unit_type(result: &mut Vec<proc_macro2::TokenStream>) { - let bitfield_unit_type = proc_macro2::TokenStream::from_str(include_str!("./bitfield_unit.rs")).unwrap(); + pub fn prepend_bitfield_unit_type( + ctx: &BindgenContext, + result: &mut Vec<proc_macro2::TokenStream> + ) { + let bitfield_unit_src = include_str!("./bitfield_unit.rs"); + let bitfield_unit_src = if ctx.options().rust_features().min_const_fn { + Cow::Borrowed(bitfield_unit_src) + } else { + Cow::Owned(bitfield_unit_src.replace("const fn ", "fn ")) + }; + let bitfield_unit_type = proc_macro2::TokenStream::from_str(&bitfield_unit_src).unwrap(); let bitfield_unit_type = quote!(#bitfield_unit_type); let items = vec![bitfield_unit_type]; diff --git a/src/features.rs b/src/features.rs index 50759c31..05f5dc42 100644 --- a/src/features.rs +++ b/src/features.rs @@ -102,6 +102,8 @@ macro_rules! rust_target_base { => Stable_1_27 => 1.27; /// Rust stable 1.28 => Stable_1_28 => 1.28; + /// Rust stable 1.30 + => Stable_1_30 => 1.30; /// Rust stable 1.33 => Stable_1_33 => 1.33; /// Nightly rust @@ -192,6 +194,11 @@ rust_feature_def!( /// repr(transparent) ([PR](https://github.com/rust-lang/rust/pull/51562)) => repr_transparent; } + Stable_1_30 { + /// `const fn` support for limited cases + /// ([PR](https://github.com/rust-lang/rust/pull/54835/) + => min_const_fn; + } Stable_1_33 { /// repr(packed(N)) ([PR](https://github.com/rust-lang/rust/pull/57049)) => repr_packed_n; |