@@ -1063,11 +1063,7 @@ fn check_struct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1063
1063
check_simd ( tcx, span, def_id) ;
1064
1064
}
1065
1065
1066
- // if struct is packed and not aligned, check fields for alignment.
1067
- // Checks for combining packed and align attrs on single struct are done elsewhere.
1068
- if tcx. adt_def ( def_id) . repr . packed ( ) && tcx. adt_def ( def_id) . repr . align == 0 {
1069
- check_packed ( tcx, span, def_id) ;
1070
- }
1066
+ check_packed ( tcx, span, def_id) ;
1071
1067
}
1072
1068
1073
1069
fn check_union < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
@@ -1478,9 +1474,15 @@ pub fn check_simd<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, def_id: DefId
1478
1474
}
1479
1475
1480
1476
fn check_packed < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , sp : Span , def_id : DefId ) {
1481
- if check_packed_inner ( tcx, def_id, & mut Vec :: new ( ) ) {
1482
- struct_span_err ! ( tcx. sess, sp, E0588 ,
1483
- "packed struct cannot transitively contain a `[repr(align)]` struct" ) . emit ( ) ;
1477
+ if tcx. adt_def ( def_id) . repr . packed ( ) {
1478
+ if tcx. adt_def ( def_id) . repr . align > 0 {
1479
+ struct_span_err ! ( tcx. sess, sp, E0587 ,
1480
+ "struct has conflicting packed and align representation hints" ) . emit ( ) ;
1481
+ }
1482
+ else if check_packed_inner ( tcx, def_id, & mut Vec :: new ( ) ) {
1483
+ struct_span_err ! ( tcx. sess, sp, E0588 ,
1484
+ "packed struct cannot transitively contain a `[repr(align)]` struct" ) . emit ( ) ;
1485
+ }
1484
1486
}
1485
1487
}
1486
1488
0 commit comments