summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md167
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/codegen/mod.rs12
-rw-r--r--src/lib.rs56
-rw-r--r--tests/expectations/tests/enum-default-bitfield.rs64
-rw-r--r--tests/expectations/tests/enum-default-consts.rs36
-rw-r--r--tests/expectations/tests/enum-default-module.rs38
-rw-r--r--tests/expectations/tests/enum-default-rust.rs41
-rw-r--r--tests/expectations/tests/enum.rs50
-rw-r--r--tests/expectations/tests/enum_explicit_type_constants.rs1
-rw-r--r--tests/expectations/tests/issue-1025-unknown-enum-repr.rs1
-rw-r--r--tests/headers/enum-default-bitfield.h10
-rw-r--r--tests/headers/enum-default-consts.h10
-rw-r--r--tests/headers/enum-default-module.h10
-rw-r--r--tests/headers/enum-default-rust.h10
-rw-r--r--tests/headers/enum.h10
17 files changed, 392 insertions, 128 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 279ba09c..4ab82009 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,97 +9,106 @@
- [Removed](#removed)
- [Fixed](#fixed)
- [Security](#security)
-- [0.54.0](#0540)
+- [0.55.0](#0550)
+ - [Removed](#removed-1)
- [Added](#added-1)
- [Changed](#changed-1)
- [Fixed](#fixed-1)
-- [0.53.3](#0533)
+- [0.54.1](#0541)
- [Added](#added-2)
- - [Fixed](#fixed-2)
-- [0.53.2](#0532)
- [Changed](#changed-2)
-- [0.53.1](#0531)
+ - [Fixed](#fixed-2)
+- [0.54.0](#0540)
- [Added](#added-3)
-- [0.53.0](#0530)
- - [Added](#added-4)
- [Changed](#changed-3)
- [Fixed](#fixed-3)
-- [0.52.0](#0520)
- - [Added](#added-5)
- - [Changed](#changed-4)
+- [0.53.3](#0533)
+ - [Added](#added-4)
- [Fixed](#fixed-4)
-- [0.51.1](#0511)
- - [Fixed](#fixed-5)
- - [Changed](#changed-5)
-- [0.51.0](#0510)
- - [Fixed](#fixed-6)
- - [Changed](#changed-6)
+- [0.53.2](#0532)
+ - [Changed](#changed-4)
+- [0.53.1](#0531)
+ - [Added](#added-5)
+- [0.53.0](#0530)
- [Added](#added-6)
-- [0.50.0](#0500)
+ - [Changed](#changed-5)
+ - [Fixed](#fixed-5)
+- [0.52.0](#0520)
- [Added](#added-7)
-- [0.49.3](#0493)
- - [Added](#added-8)
-- [0.49.2](#0492)
- - [Changed](#changed-7)
-- [0.49.1](#0491)
+ - [Changed](#changed-6)
+ - [Fixed](#fixed-6)
+- [0.51.1](#0511)
- [Fixed](#fixed-7)
+ - [Changed](#changed-7)
+- [0.51.0](#0510)
+ - [Fixed](#fixed-8)
- [Changed](#changed-8)
-- [0.49.0](#0490)
+ - [Added](#added-8)
+- [0.50.0](#0500)
- [Added](#added-9)
- - [Fixed](#fixed-8)
+- [0.49.3](#0493)
+ - [Added](#added-10)
+- [0.49.2](#0492)
- [Changed](#changed-9)
-- [0.48.1](#0481)
+- [0.49.1](#0491)
- [Fixed](#fixed-9)
-- [0.48.0](#0480)
- [Changed](#changed-10)
+- [0.49.0](#0490)
+ - [Added](#added-11)
- [Fixed](#fixed-10)
-- [0.47.3](#0473)
- [Changed](#changed-11)
-- [0.47.2](#0472)
+- [0.48.1](#0481)
- [Fixed](#fixed-11)
-- [0.47.1](#0471)
+- [0.48.0](#0480)
- [Changed](#changed-12)
- [Fixed](#fixed-12)
-- [0.47.0](#0470)
+- [0.47.3](#0473)
- [Changed](#changed-13)
+- [0.47.2](#0472)
- [Fixed](#fixed-13)
-- [0.33.1 .. 0.46.0](#0331--0460)
- - [Added](#added-10)
- - [Removed](#removed-1)
+- [0.47.1](#0471)
- [Changed](#changed-14)
- [Fixed](#fixed-14)
-- [0.33.1](#0331)
- - [Fixed](#fixed-15)
-- [0.33.0](#0330)
- - [Added](#added-11)
+- [0.47.0](#0470)
- [Changed](#changed-15)
- - [Deprecated](#deprecated-1)
+ - [Fixed](#fixed-15)
+- [0.33.1 .. 0.46.0](#0331--0460)
+ - [Added](#added-12)
- [Removed](#removed-2)
+ - [Changed](#changed-16)
- [Fixed](#fixed-16)
- - [Security](#security-1)
-- [0.32.2](#0322)
+- [0.33.1](#0331)
- [Fixed](#fixed-17)
-- [0.32.1](#0321)
- - [Fixed](#fixed-18)
-- [0.32.0](#0320)
- - [Added](#added-12)
- - [Changed](#changed-16)
- - [Fixed](#fixed-19)
-- [0.31.0](#0310)
+- [0.33.0](#0330)
- [Added](#added-13)
- [Changed](#changed-17)
- - [Deprecated](#deprecated-2)
+ - [Deprecated](#deprecated-1)
- [Removed](#removed-3)
+ - [Fixed](#fixed-18)
+ - [Security](#security-1)
+- [0.32.2](#0322)
+ - [Fixed](#fixed-19)
+- [0.32.1](#0321)
- [Fixed](#fixed-20)
-- [0.30.0](#0300)
+- [0.32.0](#0320)
- [Added](#added-14)
- [Changed](#changed-18)
- - [Deprecated](#deprecated-3)
- [Fixed](#fixed-21)
-- [0.29.0](#0290)
+- [0.31.0](#0310)
- [Added](#added-15)
- [Changed](#changed-19)
+ - [Deprecated](#deprecated-2)
+ - [Removed](#removed-4)
- [Fixed](#fixed-22)
+- [0.30.0](#0300)
+ - [Added](#added-16)
+ - [Changed](#changed-20)
+ - [Deprecated](#deprecated-3)
+ - [Fixed](#fixed-23)
+- [0.29.0](#0290)
+ - [Added](#added-17)
+ - [Changed](#changed-21)
+ - [Fixed](#fixed-24)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -135,10 +144,64 @@ Released YYYY/MM/DD
--------------------------------------------------------------------------------
+# 0.55.1
+
+Released 2020/08/24.
+
+## Fixed
+
+ * Fixed a regression where anonymous enums referenced by members or such won't
+ generate valid Rust code. (#1882).
+
+--------------------------------------------------------------------------------
+
+# 0.55.0
+
+Released 2020/08/23.
+
+## Removed
+
+ * Support for libclang 3.8 has been removed (#1830).
+
+## Added
+
+ * Added options to avoid deriving the Debug trait (#1858).
+
+ * Added options to allow to override the default anonymous field prefix (#1859).
+
+ * Added options to allow to override the default macro integer type from the
+ command line (#1863).
+
+## Changed
+
+ * Typed anonymous enums now generate better code (#1850).
+
+ * Objective-C bindings are more idiomatic now (#1847).
+
+ * Updated to clang-sys 1.0. Minimum supported rust version is 1.40 as
+ a consequence of that change.
+
+## Fixed
+
+ * Fixed constness of multi-dimensional arrays in some cases (#1861).
+
+ * Fixed wrong target given to clang when compiling with a target which doesn't
+ match the target clang expects (#1870, #1878).
+
+ * Fixed wrong flags being computed for cross-compilation cases where the target
+ wasn't explicitly provided via clang flags (#1872).
+
+Thanks again to all the awesome contributors that sent patches included in this
+release!
+
+--------------------------------------------------------------------------------
+
# 0.54.1
Released 2020/07/06.
+**Yanked**: The change in #1798 is technically breaking, see PR for details.
+
## Added
* Added ParseCallbacks::func_macro to be able to process function-like macros.
@@ -169,6 +232,8 @@ Released 2020/07/06.
Thanks to all the awesome contributors that sent patches included in this
release!
+--------------------------------------------------------------------------------
+
# 0.54.0
Released 2020/05/21.
diff --git a/Cargo.lock b/Cargo.lock
index 31096b5f..b4a55443 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -27,7 +27,7 @@ dependencies = [
[[package]]
name = "bindgen"
-version = "0.54.1"
+version = "0.55.1"
dependencies = [
"bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cexpr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/Cargo.toml b/Cargo.toml
index ddf9b5aa..7ab43a21 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,7 +14,7 @@ readme = "README.md"
repository = "https://github.com/rust-lang/rust-bindgen"
documentation = "https://docs.rs/bindgen"
homepage = "https://rust-lang.github.io/rust-bindgen/"
-version = "0.54.1"
+version = "0.55.1"
edition = "2018"
build = "build.rs"
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 60e0e592..1ad413ff 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -2478,7 +2478,6 @@ impl<'a> EnumBuilder<'a> {
repr: proc_macro2::TokenStream,
enum_variation: EnumVariation,
enum_codegen_depth: usize,
- is_ty_named: bool,
) -> Self {
let ident = Ident::new(name, Span::call_site());
@@ -2507,12 +2506,10 @@ impl<'a> EnumBuilder<'a> {
EnumVariation::Consts => {
let mut variants = Vec::new();
- if is_ty_named {
- variants.push(quote! {
- #( #attrs )*
- pub type #ident = #repr;
- });
- }
+ variants.push(quote! {
+ #( #attrs )*
+ pub type #ident = #repr;
+ });
EnumBuilder::Consts {
repr,
@@ -2901,7 +2898,6 @@ impl CodeGenerator for Enum {
repr,
variation,
item.codegen_depth(ctx),
- enum_ty.name().is_some(),
);
// A map where we keep a value -> variant relation.
diff --git a/src/lib.rs b/src/lib.rs
index 4317561b..08b93817 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1917,6 +1917,17 @@ pub struct Bindings {
pub(crate) const HOST_TARGET: &'static str =
include_str!(concat!(env!("OUT_DIR"), "/host-target.txt"));
+// Some architecture triplets are different between rust and libclang, see #1211
+// and duplicates.
+fn rust_to_clang_target(rust_target: &str) -> String {
+ if rust_target.starts_with("aarch64-apple-") {
+ let mut clang_target = "arm64-apple-".to_owned();
+ clang_target.push_str(&rust_target["aarch64-apple-".len()..]);
+ return clang_target;
+ }
+ rust_target.to_owned()
+}
+
/// Returns the effective target, and whether it was explicitly specified on the
/// clang flags.
fn find_effective_target(clang_args: &[String]) -> (String, bool) {
@@ -1937,10 +1948,10 @@ fn find_effective_target(clang_args: &[String]) -> (String, bool) {
// If we're running from a build script, try to find the cargo target.
if let Ok(t) = env::var("TARGET") {
- return (t, false);
+ return (rust_to_clang_target(&t), false);
}
- (HOST_TARGET.to_owned(), false)
+ (rust_to_clang_target(HOST_TARGET), false)
}
impl Bindings {
@@ -1963,12 +1974,15 @@ impl Bindings {
let (effective_target, explicit_target) =
find_effective_target(&options.clang_args);
- // NOTE: The effective_target == HOST_TARGET check wouldn't be sound
- // normally in some cases if we were to call a binary (if you have a
- // 32-bit clang and are building on a 64-bit system for example).
- // But since we rely on opening libclang.so, it has to be the same
- // architecture and thus the check is fine.
- if !(explicit_target || effective_target == HOST_TARGET) {
+ let is_host_build =
+ rust_to_clang_target(HOST_TARGET) == effective_target;
+
+ // NOTE: The is_host_build check wouldn't be sound normally in some
+ // cases if we were to call a binary (if you have a 32-bit clang and are
+ // building on a 64-bit system for example). But since we rely on
+ // opening libclang.so, it has to be the same architecture and thus the
+ // check is fine.
+ if !explicit_target && !is_host_build {
options
.clang_args
.insert(0, format!("--target={}", effective_target));
@@ -2088,17 +2102,14 @@ impl Bindings {
let time_phases = options.time_phases;
let mut context = BindgenContext::new(options);
- #[cfg(debug_assertions)]
- {
- if effective_target == HOST_TARGET {
- assert_eq!(
- context.target_pointer_size(),
- std::mem::size_of::<*mut ()>(),
- "{:?} {:?}",
- effective_target,
- HOST_TARGET
- );
- }
+ if is_host_build {
+ debug_assert_eq!(
+ context.target_pointer_size(),
+ std::mem::size_of::<*mut ()>(),
+ "{:?} {:?}",
+ effective_target,
+ HOST_TARGET
+ );
}
{
@@ -2109,7 +2120,7 @@ impl Bindings {
let (items, options) = codegen::codegen(context);
Ok(Bindings {
- options: options,
+ options,
module: quote! {
#( #items )*
},
@@ -2444,3 +2455,8 @@ fn commandline_flag_unit_test_function() {
.iter()
.all(|ref x| command_line_flags.contains(x),));
}
+
+#[test]
+fn test_rust_to_clang_target() {
+ assert_eq!(rust_to_clang_target("aarch64-apple-ios"), "arm64-apple-ios");
+}
diff --git a/tests/expectations/tests/enum-default-bitfield.rs b/tests/expectations/tests/enum-default-bitfield.rs
index ebf5caa4..86a04499 100644
--- a/tests/expectations/tests/enum-default-bitfield.rs
+++ b/tests/expectations/tests/enum-default-bitfield.rs
@@ -5,6 +5,70 @@
non_upper_case_globals
)]
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct foo {
+ pub member: foo__bindgen_ty_1,
+}
+pub const foo_FOO_A: foo__bindgen_ty_1 = foo__bindgen_ty_1(0);
+pub const foo_FOO_B: foo__bindgen_ty_1 = foo__bindgen_ty_1(1);
+impl ::std::ops::BitOr<foo__bindgen_ty_1> for foo__bindgen_ty_1 {
+ type Output = Self;
+ #[inline]
+ fn bitor(self, other: Self) -> Self {
+ foo__bindgen_ty_1(self.0 | other.0)
+ }
+}
+impl ::std::ops::BitOrAssign for foo__bindgen_ty_1 {
+ #[inline]
+ fn bitor_assign(&mut self, rhs: foo__bindgen_ty_1) {
+ self.0 |= rhs.0;
+ }
+}
+impl ::std::ops::BitAnd<foo__bindgen_ty_1> for foo__bindgen_ty_1 {
+ type Output = Self;
+ #[inline]
+ fn bitand(self, other: Self) -> Self {
+ foo__bindgen_ty_1(self.0 & other.0)
+ }
+}
+impl ::std::ops::BitAndAssign for foo__bindgen_ty_1 {
+ #[inline]
+ fn bitand_assign(&mut self, rhs: foo__bindgen_ty_1) {
+ self.0 &= rhs.0;
+ }
+}
+#[repr(transparent)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub struct foo__bindgen_ty_1(pub ::std::os::raw::c_uint);
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(
+ ::std::mem::size_of::<foo>(),
+ 4usize,
+ concat!("Size of: ", stringify!(foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<foo>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(foo))
+ );
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<foo>())).member as *const _ as usize },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(foo),
+ "::",
+ stringify!(member)
+ )
+ );
+}
+impl Default for foo {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
impl Foo {
pub const Bar: Foo = Foo(0);
}
diff --git a/tests/expectations/tests/enum-default-consts.rs b/tests/expectations/tests/enum-default-consts.rs
index ab496630..1f086791 100644
--- a/tests/expectations/tests/enum-default-consts.rs
+++ b/tests/expectations/tests/enum-default-consts.rs
@@ -5,6 +5,42 @@
non_upper_case_globals
)]
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct foo {
+ pub member: foo__bindgen_ty_1,
+}
+pub const foo_FOO_A: ::std::os::raw::c_uint = 0;
+pub const foo_FOO_B: ::std::os::raw::c_uint = 1;
+pub type foo__bindgen_ty_1 = ::std::os::raw::c_uint;
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(
+ ::std::mem::size_of::<foo>(),
+ 4usize,
+ concat!("Size of: ", stringify!(foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<foo>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(foo))
+ );
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<foo>())).member as *const _ as usize },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(foo),
+ "::",
+ stringify!(member)
+ )
+ );
+}
+impl Default for foo {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
pub const Foo_Bar: Foo = 0;
pub const Foo_Qux: Foo = 1;
pub type Foo = ::std::os::raw::c_uint;
diff --git a/tests/expectations/tests/enum-default-module.rs b/tests/expectations/tests/enum-default-module.rs
index a81e6ad0..7eb63a95 100644
--- a/tests/expectations/tests/enum-default-module.rs
+++ b/tests/expectations/tests/enum-default-module.rs
@@ -5,6 +5,44 @@
non_upper_case_globals
)]
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct foo {
+ pub member: foo__bindgen_ty_1::Type,
+}
+pub mod foo__bindgen_ty_1 {
+ pub type Type = ::std::os::raw::c_uint;
+ pub const FOO_A: Type = 0;
+ pub const FOO_B: Type = 1;
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(
+ ::std::mem::size_of::<foo>(),
+ 4usize,
+ concat!("Size of: ", stringify!(foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<foo>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(foo))
+ );
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<foo>())).member as *const _ as usize },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(foo),
+ "::",
+ stringify!(member)
+ )
+ );
+}
+impl Default for foo {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
pub mod Foo {
pub type Type = ::std::os::raw::c_uint;
pub const Bar: Type = 0;
diff --git a/tests/expectations/tests/enum-default-rust.rs b/tests/expectations/tests/enum-default-rust.rs
index b497a5a3..788de139 100644
--- a/tests/expectations/tests/enum-default-rust.rs
+++ b/tests/expectations/tests/enum-default-rust.rs
@@ -5,6 +5,47 @@
non_upper_case_globals
)]
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct foo {
+ pub member: foo__bindgen_ty_1,
+}
+pub const foo_FOO_A: foo__bindgen_ty_1 = foo__bindgen_ty_1::FOO_A;
+pub const foo_FOO_B: foo__bindgen_ty_1 = foo__bindgen_ty_1::FOO_B;
+#[repr(u32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum foo__bindgen_ty_1 {
+ FOO_A = 0,
+ FOO_B = 1,
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(
+ ::std::mem::size_of::<foo>(),
+ 4usize,
+ concat!("Size of: ", stringify!(foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<foo>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(foo))
+ );
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<foo>())).member as *const _ as usize },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(foo),
+ "::",
+ stringify!(member)
+ )
+ );
+}
+impl Default for foo {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum Foo {
diff --git a/tests/expectations/tests/enum.rs b/tests/expectations/tests/enum.rs
index 27a1f41b..3a1bffcb 100644
--- a/tests/expectations/tests/enum.rs
+++ b/tests/expectations/tests/enum.rs
@@ -5,15 +5,45 @@
non_upper_case_globals
)]
-#[repr(u32)]
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
-pub enum Foo {
- Bar = 0,
- Qux = 1,
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct foo {
+ pub member: foo__bindgen_ty_1,
}
-#[repr(i32)]
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
-pub enum Neg {
- MinusOne = -1,
- One = 1,
+pub const foo_FOO_A: ::std::os::raw::c_uint = 0;
+pub const foo_FOO_B: ::std::os::raw::c_uint = 1;
+pub type foo__bindgen_ty_1 = ::std::os::raw::c_uint;
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(
+ ::std::mem::size_of::<foo>(),
+ 4usize,
+ concat!("Size of: ", stringify!(foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<foo>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(foo))
+ );
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<foo>())).member as *const _ as usize },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(foo),
+ "::",
+ stringify!(member)
+ )
+ );
}
+impl Default for foo {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+pub const Foo_Bar: Foo = 0;
+pub const Foo_Qux: Foo = 1;
+pub type Foo = ::std::os::raw::c_uint;
+pub const Neg_MinusOne: Neg = -1;
+pub const Neg_One: Neg = 1;
+pub type Neg = ::std::os::raw::c_int;
diff --git a/tests/expectations/tests/enum_explicit_type_constants.rs b/tests/expectations/tests/enum_explicit_type_constants.rs
index 9406c7f2..030d64be 100644
--- a/tests/expectations/tests/enum_explicit_type_constants.rs
+++ b/tests/expectations/tests/enum_explicit_type_constants.rs
@@ -27,3 +27,4 @@ pub const BoolEnumsAreFun2_Value2: BoolEnumsAreFun2 = true;
pub type BoolEnumsAreFun2 = MyType;
pub const AnonymousVariantOne: ::std::os::raw::c_uchar = 0;
pub const AnonymousVariantTwo: ::std::os::raw::c_uchar = 1;
+pub type _bindgen_ty_1 = ::std::os::raw::c_uchar;
diff --git a/tests/expectations/tests/issue-1025-unknown-enum-repr.rs b/tests/expectations/tests/issue-1025-unknown-enum-repr.rs
index 1516c0a9..c42e167f 100644
--- a/tests/expectations/tests/issue-1025-unknown-enum-repr.rs
+++ b/tests/expectations/tests/issue-1025-unknown-enum-repr.rs
@@ -10,3 +10,4 @@
pub struct a {
pub _address: u8,
}
+pub type a__bindgen_ty_1 = i32;
diff --git a/tests/headers/enum-default-bitfield.h b/tests/headers/enum-default-bitfield.h
index be284132..5f3cb954 100644
--- a/tests/headers/enum-default-bitfield.h
+++ b/tests/headers/enum-default-bitfield.h
@@ -1,11 +1,3 @@
// bindgen-flags: --default-enum-style=bitfield --constified-enum-module=Neg
-enum Foo {
- Bar = 0,
- Qux
-};
-
-enum Neg {
- MinusOne = -1,
- One = 1,
-};
+#include "enum.h"
diff --git a/tests/headers/enum-default-consts.h b/tests/headers/enum-default-consts.h
index 448c3030..233d2718 100644
--- a/tests/headers/enum-default-consts.h
+++ b/tests/headers/enum-default-consts.h
@@ -1,11 +1,3 @@
// bindgen-flags: --default-enum-style=consts --constified-enum-module=Neg
-enum Foo {
- Bar = 0,
- Qux
-};
-
-enum Neg {
- MinusOne = -1,
- One = 1,
-};
+#include "enum.h"
diff --git a/tests/headers/enum-default-module.h b/tests/headers/enum-default-module.h
index a2f3d7ad..8c2ec1bc 100644
--- a/tests/headers/enum-default-module.h
+++ b/tests/headers/enum-default-module.h
@@ -1,11 +1,3 @@
// bindgen-flags: --default-enum-style=moduleconsts --constified-enum-module=Neg
-enum Foo {
- Bar = 0,
- Qux
-};
-
-enum Neg {
- MinusOne = -1,
- One = 1,
-};
+#include "enum.h"
diff --git a/tests/headers/enum-default-rust.h b/tests/headers/enum-default-rust.h
index 282c62f3..7fd2999f 100644
--- a/tests/headers/enum-default-rust.h
+++ b/tests/headers/enum-default-rust.h
@@ -1,11 +1,3 @@
// bindgen-flags: --default-enum-style=rust --constified-enum-module=Neg
-enum Foo {
- Bar = 0,
- Qux
-};
-
-enum Neg {
- MinusOne = -1,
- One = 1,
-};
+#include "enum.h"
diff --git a/tests/headers/enum.h b/tests/headers/enum.h
index f04c213e..901b8058 100644
--- a/tests/headers/enum.h
+++ b/tests/headers/enum.h
@@ -1,4 +1,12 @@
-// bindgen-flags: --rustified-enum ".*"
+// A few tests for enum-related issues that should be tested with all the enum
+// representations.
+
+struct foo {
+ enum {
+ FOO_A,
+ FOO_B,
+ } member;
+};
enum Foo {
Bar = 0,