Skip to content

Commit 3a6864c

Browse files
authored
Merge pull request #1530 from emilio/rustup
Update default rust target to 1.33.
2 parents 1cd8301 + a43cc2a commit 3a6864c

File tree

74 files changed

+680
-155
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

+680
-155
lines changed

CHANGELOG.md

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,53 +9,56 @@
99
- [Removed](#removed)
1010
- [Fixed](#fixed)
1111
- [Security](#security)
12-
- [0.47.3](#0473)
12+
- [0.48.0](#0480)
1313
- [Changed](#changed-1)
14-
- [0.47.2](#0472)
1514
- [Fixed](#fixed-1)
16-
- [0.47.1](#0471)
15+
- [0.47.3](#0473)
1716
- [Changed](#changed-2)
17+
- [0.47.2](#0472)
1818
- [Fixed](#fixed-2)
19-
- [0.47.0](#0470)
19+
- [0.47.1](#0471)
2020
- [Changed](#changed-3)
2121
- [Fixed](#fixed-3)
22+
- [0.47.0](#0470)
23+
- [Changed](#changed-4)
24+
- [Fixed](#fixed-4)
2225
- [0.33.1 .. 0.46.0](#0331--0460)
2326
- [Added](#added-1)
2427
- [Removed](#removed-1)
25-
- [Changed](#changed-4)
26-
- [Fixed](#fixed-4)
27-
- [0.33.1](#0331)
28+
- [Changed](#changed-5)
2829
- [Fixed](#fixed-5)
30+
- [0.33.1](#0331)
31+
- [Fixed](#fixed-6)
2932
- [0.33.0](#0330)
3033
- [Added](#added-2)
31-
- [Changed](#changed-5)
34+
- [Changed](#changed-6)
3235
- [Deprecated](#deprecated-1)
3336
- [Removed](#removed-2)
34-
- [Fixed](#fixed-6)
37+
- [Fixed](#fixed-7)
3538
- [Security](#security-1)
3639
- [0.32.2](#0322)
37-
- [Fixed](#fixed-7)
38-
- [0.32.1](#0321)
3940
- [Fixed](#fixed-8)
41+
- [0.32.1](#0321)
42+
- [Fixed](#fixed-9)
4043
- [0.32.0](#0320)
4144
- [Added](#added-3)
42-
- [Changed](#changed-6)
43-
- [Fixed](#fixed-9)
45+
- [Changed](#changed-7)
46+
- [Fixed](#fixed-10)
4447
- [0.31.0](#0310)
4548
- [Added](#added-4)
46-
- [Changed](#changed-7)
49+
- [Changed](#changed-8)
4750
- [Deprecated](#deprecated-2)
4851
- [Removed](#removed-3)
49-
- [Fixed](#fixed-10)
52+
- [Fixed](#fixed-11)
5053
- [0.30.0](#0300)
5154
- [Added](#added-5)
52-
- [Changed](#changed-8)
55+
- [Changed](#changed-9)
5356
- [Deprecated](#deprecated-3)
54-
- [Fixed](#fixed-11)
57+
- [Fixed](#fixed-12)
5558
- [0.29.0](#0290)
5659
- [Added](#added-6)
57-
- [Changed](#changed-9)
58-
- [Fixed](#fixed-12)
60+
- [Changed](#changed-10)
61+
- [Fixed](#fixed-13)
5962

6063
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
6164

@@ -89,6 +92,25 @@ Released YYYY/MM/DD
8992

9093
* TODO (or remove section if none)
9194

95+
96+
--------------------------------------------------------------------------------
97+
98+
# 0.48.0
99+
100+
Released 2019/03/04
101+
102+
## Changed
103+
104+
* Default rust target was changed to 1.33, which means that bindgen can get much
105+
more often the layout of structs right. [#1529][]
106+
107+
## Fixed
108+
109+
* Bindgen will output repr(align) just when needed for unions. [#1498][]
110+
111+
[#1529]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1529
112+
[#1498]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1498
113+
92114
--------------------------------------------------------------------------------
93115

94116
# 0.47.3

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
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 = [

bindgen-integration/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ fn test_bitfield_constructors() {
179179

180180
let mut second = bindings::bitfields::Second {
181181
_bitfield_1: bindings::bitfields::Second::new_bitfield_1(1337, true),
182-
__bindgen_align: [],
183182
};
184183
assert!(unsafe { second.assert(1337, true) });
185184

@@ -189,7 +188,6 @@ fn test_bitfield_constructors() {
189188
false,
190189
bindings::bitfields::ItemKind::ITEM_KIND_TRES,
191190
),
192-
__bindgen_align: [],
193191
};
194192
assert!(unsafe {
195193
third.assert(42, false, bindings::bitfields::ItemKind::ITEM_KIND_TRES)

src/codegen/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,7 @@ impl CodeGenerator for CompInfo {
15891589
// TODO(emilio): It'd be nice to unify this with the struct path
15901590
// above somehow.
15911591
let layout = layout.expect("Unable to get layout information?");
1592+
struct_layout.saw_union(layout);
15921593

15931594
if struct_layout.requires_explicit_align(layout) {
15941595
explicit_align = Some(layout.align);
@@ -1600,8 +1601,6 @@ impl CodeGenerator for CompInfo {
16001601
_bindgen_union_align: #ty ,
16011602
}
16021603
} else {
1603-
struct_layout.saw_union(layout);
1604-
16051604
quote! {
16061605
pub bindgen_union_field: #ty ,
16071606
}

src/codegen/struct_layout.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ impl<'a> StructLayoutTracker<'a> {
8585
name: &'a str,
8686
) -> Self {
8787
StructLayoutTracker {
88-
name: name,
89-
ctx: ctx,
90-
comp: comp,
88+
name,
89+
ctx,
90+
comp,
9191
is_packed: comp.is_packed(ctx, &ty.layout(ctx)),
9292
latest_offset: 0,
9393
padding_count: 0,

src/features.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 13 additions & 4 deletions
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)]
@@ -271,11 +274,12 @@ impl Default for rte_ipv6_tuple {
271274
}
272275
}
273276
#[repr(C)]
277+
#[repr(align(16))]
274278
#[derive(Copy, Clone)]
275279
pub union rte_thash_tuple {
276280
pub v4: rte_ipv4_tuple,
277281
pub v6: rte_ipv6_tuple,
278-
_bindgen_union_align: [u8; 48usize],
282+
_bindgen_union_align: [u128; 3usize],
279283
}
280284
#[test]
281285
fn bindgen_test_layout_rte_thash_tuple() {
@@ -284,6 +288,11 @@ fn bindgen_test_layout_rte_thash_tuple() {
284288
48usize,
285289
concat!("Size of: ", stringify!(rte_thash_tuple))
286290
);
291+
assert_eq!(
292+
::std::mem::align_of::<rte_thash_tuple>(),
293+
16usize,
294+
concat!("Alignment of ", stringify!(rte_thash_tuple))
295+
);
287296
assert_eq!(
288297
unsafe { &(*(::std::ptr::null::<rte_thash_tuple>())).v4 as *const _ as usize },
289298
0usize,

tests/expectations/tests/annotation_hide.rs

Lines changed: 1 addition & 0 deletions
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

Lines changed: 6 additions & 3 deletions
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)]

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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 73 additions & 0 deletions
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
}

0 commit comments

Comments
 (0)