File tree 2 files changed +31
-1
lines changed
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> {
128
128
} else {
129
129
0
130
130
} ;
131
- let pack = Align :: from_bytes ( pack) . unwrap ( ) ;
131
+ let pack = Align :: from_bytes ( pack) . unwrap_or ( Align :: ONE ) ;
132
132
min_pack =
133
133
Some ( if let Some ( min_pack) = min_pack { min_pack. min ( pack) } else { pack } ) ;
134
134
ReprFlags :: empty ( )
Original file line number Diff line number Diff line change @@ -220,6 +220,36 @@ fn recursive() {
220
220
) ;
221
221
}
222
222
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
+
223
253
#[ test]
224
254
fn generic ( ) {
225
255
size_and_align ! {
You can’t perform that action at this time.
0 commit comments