Skip to content

Commit

Permalink
Update default rust target to 1.33.
Browse files Browse the repository at this point in the history
Closes #1529.
  • Loading branch information
emilio committed Mar 4, 2019
1 parent 1cd8301 commit ed6e1bb
Show file tree
Hide file tree
Showing 74 changed files with 528 additions and 129 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ Released YYYY/MM/DD

* TODO (or remove section if none)


--------------------------------------------------------------------------------

# 0.48.0

Released 2019/03/04

## Changed

* Default rust target was changed to 1.33, which means that bindgen can get much
more often the layout of structs right. [#1529][]

[#1529]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1529

--------------------------------------------------------------------------------

# 0.47.3
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.47.3"
version = "0.48.0"
build = "build.rs"

include = [
Expand Down
2 changes: 1 addition & 1 deletion src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ rust_target_base!(rust_target_def);
rust_target_base!(rust_target_values_def);

/// Latest stable release of Rust
pub const LATEST_STABLE_RUST: RustTarget = RustTarget::Stable_1_21;
pub const LATEST_STABLE_RUST: RustTarget = RustTarget::Stable_1_33;

/// Create RustFeatures struct definition, new(), and a getter for each field
macro_rules! rust_feature_def {
Expand Down
19 changes: 15 additions & 4 deletions tests/expectations/tests/16-byte-alignment.rs
Original file line number Diff line number Diff line change
@@ -1,8 +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)]
#[derive(Copy, Clone)]
Expand All @@ -12,6 +15,7 @@ pub struct rte_ipv4_tuple {
pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1,
}
#[repr(C)]
#[repr(align(4))]
#[derive(Copy, Clone)]
pub union rte_ipv4_tuple__bindgen_ty_1 {
pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1,
Expand Down Expand Up @@ -145,6 +149,7 @@ pub struct rte_ipv6_tuple {
pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1,
}
#[repr(C)]
#[repr(align(4))]
#[derive(Copy, Clone)]
pub union rte_ipv6_tuple__bindgen_ty_1 {
pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1,
Expand Down Expand Up @@ -271,11 +276,12 @@ impl Default for rte_ipv6_tuple {
}
}
#[repr(C)]
#[repr(align(16))]
#[derive(Copy, Clone)]
pub union rte_thash_tuple {
pub v4: rte_ipv4_tuple,
pub v6: rte_ipv6_tuple,
_bindgen_union_align: [u8; 48usize],
_bindgen_union_align: [u128; 3usize],
}
#[test]
fn bindgen_test_layout_rte_thash_tuple() {
Expand All @@ -284,6 +290,11 @@ fn bindgen_test_layout_rte_thash_tuple() {
48usize,
concat!("Size of: ", stringify!(rte_thash_tuple))
);
assert_eq!(
::std::mem::align_of::<rte_thash_tuple>(),
16usize,
concat!("Alignment of ", stringify!(rte_thash_tuple))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<rte_thash_tuple>())).v4 as *const _ as usize },
0usize,
Expand Down
1 change: 1 addition & 0 deletions tests/expectations/tests/annotation_hide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

/// <div rustbindgen opaque></div>
#[repr(C)]
#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone)]
pub struct D {
pub _bindgen_opaque_blob: u32,
Expand Down
10 changes: 7 additions & 3 deletions tests/expectations/tests/anon_struct_in_union.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
/* 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)]
#[derive(Copy, Clone)]
pub struct s {
pub u: s__bindgen_ty_1,
}
#[repr(C)]
#[repr(align(4))]
#[derive(Copy, Clone)]
pub union s__bindgen_ty_1 {
pub field: s__bindgen_ty_1_inner,
Expand Down
1 change: 1 addition & 0 deletions tests/expectations/tests/anon_union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub struct TErrorResult_DOMExceptionInfo {
_unused: [u8; 0],
}
#[repr(C)]
#[repr(align(8))]
pub union TErrorResult__bindgen_ty_1 {
pub mMessage: *mut TErrorResult_Message,
pub mDOMExceptionInfo: *mut TErrorResult_DOMExceptionInfo,
Expand Down
8 changes: 4 additions & 4 deletions tests/expectations/tests/bitfield-enum-basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl ::std::ops::BitAndAssign for Foo {
self.0 &= rhs.0;
}
}
#[repr(C)]
#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Foo(pub i32);
impl Buz {
Expand Down Expand Up @@ -86,7 +86,7 @@ impl ::std::ops::BitAndAssign for Buz {
self.0 &= rhs.0;
}
}
#[repr(C)]
#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Buz(pub i8);
pub const NS_FOO: _bindgen_ty_1 = _bindgen_ty_1(1);
Expand Down Expand Up @@ -117,7 +117,7 @@ impl ::std::ops::BitAndAssign for _bindgen_ty_1 {
self.0 &= rhs.0;
}
}
#[repr(C)]
#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct _bindgen_ty_1(pub u32);
#[repr(C)]
Expand Down Expand Up @@ -153,7 +153,7 @@ impl ::std::ops::BitAndAssign for Dummy__bindgen_ty_1 {
self.0 &= rhs.0;
}
}
#[repr(C)]
#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Dummy__bindgen_ty_1(pub u32);
#[test]
Expand Down
73 changes: 73 additions & 0 deletions tests/expectations/tests/bitfield-large.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ where
}
}
#[repr(C)]
#[repr(align(16))]
#[derive(Debug, Default, Copy, Clone)]
pub struct HasBigBitfield {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize], u64>,
Expand All @@ -101,8 +102,37 @@ fn bindgen_test_layout_HasBigBitfield() {
16usize,
concat!("Size of: ", stringify!(HasBigBitfield))
);
assert_eq!(
::std::mem::align_of::<HasBigBitfield>(),
16usize,
concat!("Alignment of ", stringify!(HasBigBitfield))
);
}
impl HasBigBitfield {
#[inline]
pub fn x(&self) -> i128 {
unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 128u8) as u128) }
}
#[inline]
pub fn set_x(&mut self, val: i128) {
unsafe {
let val: u128 = ::std::mem::transmute(val);
self._bitfield_1.set(0usize, 128u8, val as u64)
}
}
#[inline]
pub fn new_bitfield_1(x: i128) -> __BindgenBitfieldUnit<[u8; 16usize], u64> {
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize], u64> =
Default::default();
__bindgen_bitfield_unit.set(0usize, 128u8, {
let x: u128 = unsafe { ::std::mem::transmute(x) };
x as u64
});
__bindgen_bitfield_unit
}
}
#[repr(C)]
#[repr(align(16))]
#[derive(Debug, Default, Copy, Clone)]
pub struct HasTwoBigBitfields {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize], u64>,
Expand All @@ -114,4 +144,47 @@ fn bindgen_test_layout_HasTwoBigBitfields() {
16usize,
concat!("Size of: ", stringify!(HasTwoBigBitfields))
);
assert_eq!(
::std::mem::align_of::<HasTwoBigBitfields>(),
16usize,
concat!("Alignment of ", stringify!(HasTwoBigBitfields))
);
}
impl HasTwoBigBitfields {
#[inline]
pub fn x(&self) -> i128 {
unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 80u8) as u128) }
}
#[inline]
pub fn set_x(&mut self, val: i128) {
unsafe {
let val: u128 = ::std::mem::transmute(val);
self._bitfield_1.set(0usize, 80u8, val as u64)
}
}
#[inline]
pub fn y(&self) -> i128 {
unsafe { ::std::mem::transmute(self._bitfield_1.get(80usize, 48u8) as u128) }
}
#[inline]
pub fn set_y(&mut self, val: i128) {
unsafe {
let val: u128 = ::std::mem::transmute(val);
self._bitfield_1.set(80usize, 48u8, val as u64)
}
}
#[inline]
pub fn new_bitfield_1(x: i128, y: i128) -> __BindgenBitfieldUnit<[u8; 16usize], u64> {
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize], u64> =
Default::default();
__bindgen_bitfield_unit.set(0usize, 80u8, {
let x: u128 = unsafe { ::std::mem::transmute(x) };
x as u64
});
__bindgen_bitfield_unit.set(80usize, 48u8, {
let y: u128 = unsafe { ::std::mem::transmute(y) };
y as u64
});
__bindgen_bitfield_unit
}
}
10 changes: 5 additions & 5 deletions tests/expectations/tests/bitfield_align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ where
}
}
#[repr(C)]
#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone)]
pub struct A {
pub x: ::std::os::raw::c_uchar,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize], u8>,
pub y: ::std::os::raw::c_uchar,
pub __bindgen_align: [u32; 0usize],
}
#[test]
fn bindgen_test_layout_A() {
Expand Down Expand Up @@ -290,10 +290,10 @@ impl A {
}
}
#[repr(C)]
#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone)]
pub struct B {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u32>,
pub __bindgen_align: [u32; 0usize],
}
#[test]
fn bindgen_test_layout_B() {
Expand Down Expand Up @@ -421,11 +421,11 @@ impl C {
}
}
#[repr(C)]
#[repr(align(2))]
#[derive(Debug, Default, Copy, Clone)]
pub struct Date1 {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 3usize], u8>,
pub __bindgen_padding_0: u8,
pub __bindgen_align: [u16; 0usize],
}
#[test]
fn bindgen_test_layout_Date1() {
Expand Down Expand Up @@ -514,10 +514,10 @@ impl Date1 {
}
}
#[repr(C)]
#[repr(align(2))]
#[derive(Debug, Default, Copy, Clone)]
pub struct Date2 {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u8>,
pub __bindgen_align: [u16; 0usize],
}
#[test]
fn bindgen_test_layout_Date2() {
Expand Down Expand Up @@ -622,11 +622,11 @@ impl Date2 {
}
}
#[repr(C)]
#[repr(align(2))]
#[derive(Debug, Default, Copy, Clone)]
pub struct Date3 {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 3usize], u8>,
pub byte: ::std::os::raw::c_uchar,
pub __bindgen_align: [u16; 0usize],
}
#[test]
fn bindgen_test_layout_Date3() {
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/bitfield_align_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ pub enum MyEnum {
FOUR = 3,
}
#[repr(C)]
#[repr(align(8))]
#[derive(Debug, Copy, Clone)]
pub struct TaggedPtr {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize], u64>,
pub __bindgen_align: [u64; 0usize],
}
#[test]
fn bindgen_test_layout_TaggedPtr() {
Expand Down
10 changes: 7 additions & 3 deletions tests/expectations/tests/bitfield_large_overflow.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/* 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(8))]
#[derive(Debug, Default, Copy, Clone)]
pub struct _bindgen_ty_1 {
pub _bindgen_opaque_blob: [u64; 10usize],
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/bitfield_method_mangling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ where
}
}
#[repr(C)]
#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone)]
pub struct mach_msg_type_descriptor_t {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u32>,
pub __bindgen_align: [u32; 0usize],
}
#[test]
fn bindgen_test_layout_mach_msg_type_descriptor_t() {
Expand Down
1 change: 1 addition & 0 deletions tests/expectations/tests/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ impl Default for IncompleteArrayNonCopiable {
}
}
#[repr(C)]
#[repr(align(4))]
#[derive(Copy, Clone)]
pub union Union {
pub d: f32,
Expand Down

0 comments on commit ed6e1bb

Please sign in to comment.