diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-08-24 14:40:33 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-08-24 15:32:34 +0200 |
commit | 5133e49a55b342d332ac08248e96b73200b5f3a6 (patch) | |
tree | 163bf4afee1d02348edc2d2b19d2147658f7b400 | |
parent | e36b67f7ce429d1d17e5e44028716d7de4138928 (diff) |
Don't generate a __bindgen_align field if we support repr(align).
-rw-r--r-- | src/codegen/mod.rs | 10 | ||||
-rw-r--r-- | tests/expectations/tests/issue-1291.rs | 8 | ||||
-rw-r--r-- | tests/expectations/tests/repr-align.rs | 9 |
3 files changed, 18 insertions, 9 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 15b0a139..aee04318 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -1555,10 +1555,12 @@ impl CodeGenerator for CompInfo { packed = true; } else { explicit_align = Some(layout.align); - let ty = helpers::blob(Layout::new(0, layout.align)); - fields.push(quote! { - pub __bindgen_align: #ty , - }); + if !ctx.options().rust_features.repr_align { + let ty = helpers::blob(Layout::new(0, layout.align)); + fields.push(quote! { + pub __bindgen_align: #ty , + }); + } } } } diff --git a/tests/expectations/tests/issue-1291.rs b/tests/expectations/tests/issue-1291.rs index a2330541..f92d364e 100644 --- a/tests/expectations/tests/issue-1291.rs +++ b/tests/expectations/tests/issue-1291.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[repr(align(16))] @@ -22,7 +27,6 @@ pub struct RTCRay { pub primID: ::std::os::raw::c_uint, pub instID: ::std::os::raw::c_uint, pub __bindgen_padding_0: [u32; 3usize], - pub __bindgen_align: [u8; 0usize], } #[test] fn bindgen_test_layout_RTCRay() { diff --git a/tests/expectations/tests/repr-align.rs b/tests/expectations/tests/repr-align.rs index 1827ca9d..8a0c9023 100644 --- a/tests/expectations/tests/repr-align.rs +++ b/tests/expectations/tests/repr-align.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #![cfg(feature = "nightly")] #[repr(C)] @@ -9,7 +14,6 @@ pub struct a { pub b: ::std::os::raw::c_int, pub c: ::std::os::raw::c_int, - pub __bindgen_align: [u64; 0usize], } #[test] fn bindgen_test_layout_a() { @@ -40,7 +44,6 @@ fn bindgen_test_layout_a() { pub struct b { pub b: ::std::os::raw::c_int, pub c: ::std::os::raw::c_int, - pub __bindgen_align: [u64; 0usize], } #[test] fn bindgen_test_layout_b() { |