@@ -64,15 +64,21 @@ should match the equivalent struct in C.
64
64
` #[repr(packed)] ` and ` #[repr(pack = "1")] ` should have identical behavior.
65
65
66
66
Because this lowers the effective alignment of fields in the same way that
67
- ` #[repr(packed)] ` does (which caused https://github.com/rust-lang/rust/issues/27060 ),
68
- while accessing a field should be safe, borrowing a field should be unsafe.
67
+ ` #[repr(packed)] ` does (which caused [ issue #27060 ] [ gh27060 ] ), while accessing a
68
+ field should be safe, borrowing a field should be unsafe.
69
+
70
+ Specifying ` #[repr(packed)] ` and ` #[repr(pack = "N")] ` where N is not 1 should
71
+ result in an error.
72
+
73
+ Specifying ` #[repr(pack = "A")] ` and ` #[repr(align = "B")] ` should still pack
74
+ together fields with the packing specified, but then increase the overall
75
+ alignment to the alignment specified. Depends on [ RFC #1358 ] [ rfc1358 ] landing.
69
76
70
77
# Drawbacks
71
78
[ drawbacks ] : #drawbacks
72
79
73
- This would unfortunately make my life easier even though one of the unstated
74
- goals of Rust is to make my life as difficult as possible when doing FFI with
75
- Windows API.
80
+ Duplication in the language where ` #[repr(packed)] ` and ` #[repr(pack = "1")] `
81
+ have identical behavior.
76
82
77
83
# Alternatives
78
84
[ alternatives ] : #alternatives
@@ -91,3 +97,6 @@ Windows API.
91
97
it match the behavior of other C/C++ compilers as well?
92
98
* Should it still be safe to borrow fields whose alignment is less than or equal
93
99
to the specified packing or should all field borrows be unsafe?
100
+
101
+ [ gh27060 ] : https://github.com/rust-lang/rust/issues/27060
102
+ [ rfc1358 ] : https://github.com/rust-lang/rfcs/pull/1358
0 commit comments