This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ fn parse_repr_tt(tt: &Subtree) -> Option<ReprOptions> {
128128 } else {
129129 0
130130 } ;
131- let pack = Align :: from_bytes ( pack) . unwrap ( ) ;
131+ let pack = Align :: from_bytes ( pack) . unwrap_or ( Align :: ONE ) ;
132132 min_pack =
133133 Some ( if let Some ( min_pack) = min_pack { min_pack. min ( pack) } else { pack } ) ;
134134 ReprFlags :: empty ( )
Original file line number Diff line number Diff line change @@ -220,6 +220,36 @@ fn recursive() {
220220 ) ;
221221}
222222
223+ #[ test]
224+ fn repr_packed ( ) {
225+ size_and_align ! {
226+ #[ repr( packed) ]
227+ struct Goal ;
228+ }
229+ size_and_align ! {
230+ #[ repr( packed( 2 ) ) ]
231+ struct Goal ;
232+ }
233+ size_and_align ! {
234+ #[ repr( packed( 4 ) ) ]
235+ struct Goal ;
236+ }
237+ size_and_align ! {
238+ #[ repr( packed) ]
239+ struct Goal ( i32 ) ;
240+ }
241+ size_and_align ! {
242+ #[ repr( packed( 2 ) ) ]
243+ struct Goal ( i32 ) ;
244+ }
245+ size_and_align ! {
246+ #[ repr( packed( 4 ) ) ]
247+ struct Goal ( i32 ) ;
248+ }
249+
250+ check_size_and_align ( "#[repr(packed(5))] struct Goal(i32);" , "" , 4 , 1 ) ;
251+ }
252+
223253#[ test]
224254fn generic ( ) {
225255 size_and_align ! {
You can’t perform that action at this time.
0 commit comments