Skip to content

Commit 86cc061

Browse files
authored
Test repr(packed) with an explicit alignment. (#794)
1 parent 0307fca commit 86cc061

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/adapter/tests.rs

+24
Original file line numberDiff line numberDiff line change
@@ -5692,6 +5692,24 @@ fn struct_field_positions() {
56925692
field_name: "z".into(),
56935693
field_position: 3,
56945694
},
5695+
Output {
5696+
struct_name: "ReprPackedWithAlignment".into(),
5697+
struct_type: "plain".into(),
5698+
field_name: "x".into(),
5699+
field_position: 1,
5700+
},
5701+
Output {
5702+
struct_name: "ReprPackedWithAlignment".into(),
5703+
struct_type: "plain".into(),
5704+
field_name: "y".into(),
5705+
field_position: 2,
5706+
},
5707+
Output {
5708+
struct_name: "ReprPackedWithAlignment".into(),
5709+
struct_type: "plain".into(),
5710+
field_name: "z".into(),
5711+
field_position: 3,
5712+
},
56955713
Output {
56965714
struct_name: "ReprCTupleStruct".into(),
56975715
struct_type: "tuple".into(),
@@ -6102,6 +6120,12 @@ fn struct_repr_attributes() {
61026120
attr_raw: "#[repr(packed)]".into(),
61036121
attr_repr_kind: "packed".into(),
61046122
},
6123+
Output {
6124+
name: "ReprPackedWithAlignment".into(),
6125+
attrs: vec!["#[repr(packed(2))]".into()],
6126+
attr_raw: "#[repr(packed(2))]".into(),
6127+
attr_repr_kind: "packed".into(),
6128+
},
61056129
Output {
61066130
name: "ReprCTupleStruct".into(),
61076131
attrs: vec!["#[repr(C)]".into()],

test_crates/struct_fields_position/src/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ pub struct ReprPackedStruct {
2020
pub z: bool,
2121
}
2222

23+
#[repr(packed(2))]
24+
pub struct ReprPackedWithAlignment {
25+
pub x: i32,
26+
pub y: bool,
27+
pub z: String,
28+
}
29+
2330
#[repr(C)]
2431
pub struct ReprCTupleStruct(pub i32, pub String, pub bool);
2532

0 commit comments

Comments
 (0)