Skip to content

Commit 57aade8

Browse files
authored
Test repr(packed) with an explicit alignment. (#794) (#796)
1 parent 1bf73ff commit 57aade8

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
@@ -5638,6 +5638,24 @@ fn struct_field_positions() {
56385638
field_name: "z".into(),
56395639
field_position: 3,
56405640
},
5641+
Output {
5642+
struct_name: "ReprPackedWithAlignment".into(),
5643+
struct_type: "plain".into(),
5644+
field_name: "x".into(),
5645+
field_position: 1,
5646+
},
5647+
Output {
5648+
struct_name: "ReprPackedWithAlignment".into(),
5649+
struct_type: "plain".into(),
5650+
field_name: "y".into(),
5651+
field_position: 2,
5652+
},
5653+
Output {
5654+
struct_name: "ReprPackedWithAlignment".into(),
5655+
struct_type: "plain".into(),
5656+
field_name: "z".into(),
5657+
field_position: 3,
5658+
},
56415659
Output {
56425660
struct_name: "ReprCTupleStruct".into(),
56435661
struct_type: "tuple".into(),
@@ -6048,6 +6066,12 @@ fn struct_repr_attributes() {
60486066
attr_raw: "#[repr(packed)]".into(),
60496067
attr_repr_kind: "packed".into(),
60506068
},
6069+
Output {
6070+
name: "ReprPackedWithAlignment".into(),
6071+
attrs: vec!["#[repr(packed(2))]".into()],
6072+
attr_raw: "#[repr(packed(2))]".into(),
6073+
attr_repr_kind: "packed".into(),
6074+
},
60516075
Output {
60526076
name: "ReprCTupleStruct".into(),
60536077
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)