@@ -1462,16 +1462,18 @@ impl BackendRepr {
1462
1462
matches ! ( * self , BackendRepr :: Scalar ( s) if s. is_bool( ) )
1463
1463
}
1464
1464
1465
- /// Returns the fixed alignment of this ABI, if any is mandated.
1466
- pub fn inherent_align < C : HasDataLayout > ( & self , cx : & C ) -> Option < AbiAndPrefAlign > {
1467
- Some ( match * self {
1468
- BackendRepr :: Scalar ( s) => s. align ( cx) ,
1469
- BackendRepr :: ScalarPair ( s1, s2) => s1. align ( cx) . max ( s2. align ( cx) ) ,
1465
+ /// fixed alignment of this repr, if any is mandated
1466
+ ///
1467
+ /// NOTE: returning None is not an error! not all types have set alignments
1468
+ pub fn required_align < C : HasDataLayout > ( & self , cx : & C ) -> Option < Align > {
1469
+ match * self {
1470
+ BackendRepr :: Scalar ( s) => Some ( s. align ( cx) . abi ) ,
1471
+ BackendRepr :: ScalarPair ( s1, s2) => Some ( s1. align ( cx) . max ( s2. align ( cx) ) . abi ) ,
1470
1472
BackendRepr :: Vector { element, count } => {
1471
- cx. data_layout ( ) . vector_align ( element. size ( cx) * count)
1473
+ Some ( cx. data_layout ( ) . vector_align ( element. size ( cx) * count) . abi )
1472
1474
}
1473
- BackendRepr :: Uninhabited | BackendRepr :: Memory { .. } => return None ,
1474
- } )
1475
+ BackendRepr :: Uninhabited | BackendRepr :: Memory { .. } => None ,
1476
+ }
1475
1477
}
1476
1478
1477
1479
/// Returns the fixed size of this ABI, if any is mandated.
@@ -1484,12 +1486,12 @@ impl BackendRepr {
1484
1486
BackendRepr :: ScalarPair ( s1, s2) => {
1485
1487
// May have some padding between the pair.
1486
1488
let field2_offset = s1. size ( cx) . align_to ( s2. align ( cx) . abi ) ;
1487
- ( field2_offset + s2. size ( cx) ) . align_to ( self . inherent_align ( cx) ?. abi )
1489
+ ( field2_offset + s2. size ( cx) ) . align_to ( self . required_align ( cx) ?)
1488
1490
}
1489
1491
BackendRepr :: Vector { element, count } => {
1490
1492
// No padding in vectors, except possibly for trailing padding
1491
1493
// to make the size a multiple of align (e.g. for vectors of size 3).
1492
- ( element. size ( cx) * count) . align_to ( self . inherent_align ( cx) ?. abi )
1494
+ ( element. size ( cx) * count) . align_to ( self . required_align ( cx) ?)
1493
1495
}
1494
1496
BackendRepr :: Uninhabited | BackendRepr :: Memory { .. } => return None ,
1495
1497
} )
0 commit comments