Skip to content

Commit ed6e1bb

Browse files
committed
Update default rust target to 1.33.
Closes #1529.
1 parent 1cd8301 commit ed6e1bb

File tree

74 files changed

+528
-129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+528
-129
lines changed

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ Released YYYY/MM/DD
8989

9090
* TODO (or remove section if none)
9191

92+
93+
--------------------------------------------------------------------------------
94+
95+
# 0.48.0
96+
97+
Released 2019/03/04
98+
99+
## Changed
100+
101+
* Default rust target was changed to 1.33, which means that bindgen can get much
102+
more often the layout of structs right. [#1529][]
103+
104+
[#1529]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1529
105+
92106
--------------------------------------------------------------------------------
93107

94108
# 0.47.3

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ readme = "README.md"
1414
repository = "https://github.com/rust-lang/rust-bindgen"
1515
documentation = "https://docs.rs/bindgen"
1616
homepage = "https://rust-lang.github.io/rust-bindgen/"
17-
version = "0.47.3"
17+
version = "0.48.0"
1818
build = "build.rs"
1919

2020
include = [

src/features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ rust_target_base!(rust_target_def);
114114
rust_target_base!(rust_target_values_def);
115115

116116
/// Latest stable release of Rust
117-
pub const LATEST_STABLE_RUST: RustTarget = RustTarget::Stable_1_21;
117+
pub const LATEST_STABLE_RUST: RustTarget = RustTarget::Stable_1_33;
118118

119119
/// Create RustFeatures struct definition, new(), and a getter for each field
120120
macro_rules! rust_feature_def {

tests/expectations/tests/16-byte-alignment.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
/* automatically generated by rust-bindgen */
22

3-
4-
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
5-
3+
#![allow(
4+
dead_code,
5+
non_snake_case,
6+
non_camel_case_types,
7+
non_upper_case_globals
8+
)]
69

710
#[repr(C)]
811
#[derive(Copy, Clone)]
@@ -12,6 +15,7 @@ pub struct rte_ipv4_tuple {
1215
pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1,
1316
}
1417
#[repr(C)]
18+
#[repr(align(4))]
1519
#[derive(Copy, Clone)]
1620
pub union rte_ipv4_tuple__bindgen_ty_1 {
1721
pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1,
@@ -145,6 +149,7 @@ pub struct rte_ipv6_tuple {
145149
pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1,
146150
}
147151
#[repr(C)]
152+
#[repr(align(4))]
148153
#[derive(Copy, Clone)]
149154
pub union rte_ipv6_tuple__bindgen_ty_1 {
150155
pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1,
@@ -271,11 +276,12 @@ impl Default for rte_ipv6_tuple {
271276
}
272277
}
273278
#[repr(C)]
279+
#[repr(align(16))]
274280
#[derive(Copy, Clone)]
275281
pub union rte_thash_tuple {
276282
pub v4: rte_ipv4_tuple,
277283
pub v6: rte_ipv6_tuple,
278-
_bindgen_union_align: [u8; 48usize],
284+
_bindgen_union_align: [u128; 3usize],
279285
}
280286
#[test]
281287
fn bindgen_test_layout_rte_thash_tuple() {
@@ -284,6 +290,11 @@ fn bindgen_test_layout_rte_thash_tuple() {
284290
48usize,
285291
concat!("Size of: ", stringify!(rte_thash_tuple))
286292
);
293+
assert_eq!(
294+
::std::mem::align_of::<rte_thash_tuple>(),
295+
16usize,
296+
concat!("Alignment of ", stringify!(rte_thash_tuple))
297+
);
287298
assert_eq!(
288299
unsafe { &(*(::std::ptr::null::<rte_thash_tuple>())).v4 as *const _ as usize },
289300
0usize,

tests/expectations/tests/annotation_hide.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
/// <div rustbindgen opaque></div>
1111
#[repr(C)]
12+
#[repr(align(4))]
1213
#[derive(Debug, Default, Copy, Clone)]
1314
pub struct D {
1415
pub _bindgen_opaque_blob: u32,

tests/expectations/tests/anon_struct_in_union.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
/* automatically generated by rust-bindgen */
22

3-
4-
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
5-
3+
#![allow(
4+
dead_code,
5+
non_snake_case,
6+
non_camel_case_types,
7+
non_upper_case_globals
8+
)]
69

710
#[repr(C)]
811
#[derive(Copy, Clone)]
912
pub struct s {
1013
pub u: s__bindgen_ty_1,
1114
}
1215
#[repr(C)]
16+
#[repr(align(4))]
1317
#[derive(Copy, Clone)]
1418
pub union s__bindgen_ty_1 {
1519
pub field: s__bindgen_ty_1_inner,

tests/expectations/tests/anon_union.rs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub struct TErrorResult_DOMExceptionInfo {
3333
_unused: [u8; 0],
3434
}
3535
#[repr(C)]
36+
#[repr(align(8))]
3637
pub union TErrorResult__bindgen_ty_1 {
3738
pub mMessage: *mut TErrorResult_Message,
3839
pub mDOMExceptionInfo: *mut TErrorResult_DOMExceptionInfo,

tests/expectations/tests/bitfield-enum-basic.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl ::std::ops::BitAndAssign for Foo {
4545
self.0 &= rhs.0;
4646
}
4747
}
48-
#[repr(C)]
48+
#[repr(transparent)]
4949
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
5050
pub struct Foo(pub i32);
5151
impl Buz {
@@ -86,7 +86,7 @@ impl ::std::ops::BitAndAssign for Buz {
8686
self.0 &= rhs.0;
8787
}
8888
}
89-
#[repr(C)]
89+
#[repr(transparent)]
9090
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
9191
pub struct Buz(pub i8);
9292
pub const NS_FOO: _bindgen_ty_1 = _bindgen_ty_1(1);
@@ -117,7 +117,7 @@ impl ::std::ops::BitAndAssign for _bindgen_ty_1 {
117117
self.0 &= rhs.0;
118118
}
119119
}
120-
#[repr(C)]
120+
#[repr(transparent)]
121121
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
122122
pub struct _bindgen_ty_1(pub u32);
123123
#[repr(C)]
@@ -153,7 +153,7 @@ impl ::std::ops::BitAndAssign for Dummy__bindgen_ty_1 {
153153
self.0 &= rhs.0;
154154
}
155155
}
156-
#[repr(C)]
156+
#[repr(transparent)]
157157
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
158158
pub struct Dummy__bindgen_ty_1(pub u32);
159159
#[test]

tests/expectations/tests/bitfield-large.rs

+73
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ where
9090
}
9191
}
9292
#[repr(C)]
93+
#[repr(align(16))]
9394
#[derive(Debug, Default, Copy, Clone)]
9495
pub struct HasBigBitfield {
9596
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize], u64>,
@@ -101,8 +102,37 @@ fn bindgen_test_layout_HasBigBitfield() {
101102
16usize,
102103
concat!("Size of: ", stringify!(HasBigBitfield))
103104
);
105+
assert_eq!(
106+
::std::mem::align_of::<HasBigBitfield>(),
107+
16usize,
108+
concat!("Alignment of ", stringify!(HasBigBitfield))
109+
);
110+
}
111+
impl HasBigBitfield {
112+
#[inline]
113+
pub fn x(&self) -> i128 {
114+
unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 128u8) as u128) }
115+
}
116+
#[inline]
117+
pub fn set_x(&mut self, val: i128) {
118+
unsafe {
119+
let val: u128 = ::std::mem::transmute(val);
120+
self._bitfield_1.set(0usize, 128u8, val as u64)
121+
}
122+
}
123+
#[inline]
124+
pub fn new_bitfield_1(x: i128) -> __BindgenBitfieldUnit<[u8; 16usize], u64> {
125+
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize], u64> =
126+
Default::default();
127+
__bindgen_bitfield_unit.set(0usize, 128u8, {
128+
let x: u128 = unsafe { ::std::mem::transmute(x) };
129+
x as u64
130+
});
131+
__bindgen_bitfield_unit
132+
}
104133
}
105134
#[repr(C)]
135+
#[repr(align(16))]
106136
#[derive(Debug, Default, Copy, Clone)]
107137
pub struct HasTwoBigBitfields {
108138
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize], u64>,
@@ -114,4 +144,47 @@ fn bindgen_test_layout_HasTwoBigBitfields() {
114144
16usize,
115145
concat!("Size of: ", stringify!(HasTwoBigBitfields))
116146
);
147+
assert_eq!(
148+
::std::mem::align_of::<HasTwoBigBitfields>(),
149+
16usize,
150+
concat!("Alignment of ", stringify!(HasTwoBigBitfields))
151+
);
152+
}
153+
impl HasTwoBigBitfields {
154+
#[inline]
155+
pub fn x(&self) -> i128 {
156+
unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 80u8) as u128) }
157+
}
158+
#[inline]
159+
pub fn set_x(&mut self, val: i128) {
160+
unsafe {
161+
let val: u128 = ::std::mem::transmute(val);
162+
self._bitfield_1.set(0usize, 80u8, val as u64)
163+
}
164+
}
165+
#[inline]
166+
pub fn y(&self) -> i128 {
167+
unsafe { ::std::mem::transmute(self._bitfield_1.get(80usize, 48u8) as u128) }
168+
}
169+
#[inline]
170+
pub fn set_y(&mut self, val: i128) {
171+
unsafe {
172+
let val: u128 = ::std::mem::transmute(val);
173+
self._bitfield_1.set(80usize, 48u8, val as u64)
174+
}
175+
}
176+
#[inline]
177+
pub fn new_bitfield_1(x: i128, y: i128) -> __BindgenBitfieldUnit<[u8; 16usize], u64> {
178+
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize], u64> =
179+
Default::default();
180+
__bindgen_bitfield_unit.set(0usize, 80u8, {
181+
let x: u128 = unsafe { ::std::mem::transmute(x) };
182+
x as u64
183+
});
184+
__bindgen_bitfield_unit.set(80usize, 48u8, {
185+
let y: u128 = unsafe { ::std::mem::transmute(y) };
186+
y as u64
187+
});
188+
__bindgen_bitfield_unit
189+
}
117190
}

tests/expectations/tests/bitfield_align.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ where
9090
}
9191
}
9292
#[repr(C)]
93+
#[repr(align(4))]
9394
#[derive(Debug, Default, Copy, Clone)]
9495
pub struct A {
9596
pub x: ::std::os::raw::c_uchar,
9697
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize], u8>,
9798
pub y: ::std::os::raw::c_uchar,
98-
pub __bindgen_align: [u32; 0usize],
9999
}
100100
#[test]
101101
fn bindgen_test_layout_A() {
@@ -290,10 +290,10 @@ impl A {
290290
}
291291
}
292292
#[repr(C)]
293+
#[repr(align(4))]
293294
#[derive(Debug, Default, Copy, Clone)]
294295
pub struct B {
295296
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u32>,
296-
pub __bindgen_align: [u32; 0usize],
297297
}
298298
#[test]
299299
fn bindgen_test_layout_B() {
@@ -421,11 +421,11 @@ impl C {
421421
}
422422
}
423423
#[repr(C)]
424+
#[repr(align(2))]
424425
#[derive(Debug, Default, Copy, Clone)]
425426
pub struct Date1 {
426427
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 3usize], u8>,
427428
pub __bindgen_padding_0: u8,
428-
pub __bindgen_align: [u16; 0usize],
429429
}
430430
#[test]
431431
fn bindgen_test_layout_Date1() {
@@ -514,10 +514,10 @@ impl Date1 {
514514
}
515515
}
516516
#[repr(C)]
517+
#[repr(align(2))]
517518
#[derive(Debug, Default, Copy, Clone)]
518519
pub struct Date2 {
519520
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u8>,
520-
pub __bindgen_align: [u16; 0usize],
521521
}
522522
#[test]
523523
fn bindgen_test_layout_Date2() {
@@ -622,11 +622,11 @@ impl Date2 {
622622
}
623623
}
624624
#[repr(C)]
625+
#[repr(align(2))]
625626
#[derive(Debug, Default, Copy, Clone)]
626627
pub struct Date3 {
627628
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 3usize], u8>,
628629
pub byte: ::std::os::raw::c_uchar,
629-
pub __bindgen_align: [u16; 0usize],
630630
}
631631
#[test]
632632
fn bindgen_test_layout_Date3() {

tests/expectations/tests/bitfield_align_2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ pub enum MyEnum {
9898
FOUR = 3,
9999
}
100100
#[repr(C)]
101+
#[repr(align(8))]
101102
#[derive(Debug, Copy, Clone)]
102103
pub struct TaggedPtr {
103104
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize], u64>,
104-
pub __bindgen_align: [u64; 0usize],
105105
}
106106
#[test]
107107
fn bindgen_test_layout_TaggedPtr() {

tests/expectations/tests/bitfield_large_overflow.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
/* automatically generated by rust-bindgen */
22

3-
4-
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
5-
3+
#![allow(
4+
dead_code,
5+
non_snake_case,
6+
non_camel_case_types,
7+
non_upper_case_globals
8+
)]
69

710
#[repr(C)]
11+
#[repr(align(8))]
812
#[derive(Debug, Default, Copy, Clone)]
913
pub struct _bindgen_ty_1 {
1014
pub _bindgen_opaque_blob: [u64; 10usize],

tests/expectations/tests/bitfield_method_mangling.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ where
9090
}
9191
}
9292
#[repr(C)]
93+
#[repr(align(4))]
9394
#[derive(Debug, Default, Copy, Clone)]
9495
pub struct mach_msg_type_descriptor_t {
9596
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u32>,
96-
pub __bindgen_align: [u32; 0usize],
9797
}
9898
#[test]
9999
fn bindgen_test_layout_mach_msg_type_descriptor_t() {

tests/expectations/tests/class.rs

+1
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ impl Default for IncompleteArrayNonCopiable {
335335
}
336336
}
337337
#[repr(C)]
338+
#[repr(align(4))]
338339
#[derive(Copy, Clone)]
339340
pub union Union {
340341
pub d: f32,

0 commit comments

Comments
 (0)