@@ -813,7 +813,7 @@ where
813
813
break ;
814
814
}
815
815
} ;
816
- if let Some ( ( old_common_prim , common_offset) ) = common_prim {
816
+ if let Some ( ( old_prim , common_offset) ) = common_prim {
817
817
// All variants must be at the same offset
818
818
if offset != common_offset {
819
819
common_prim = None ;
@@ -822,35 +822,28 @@ where
822
822
// This is pretty conservative. We could go fancier
823
823
// by realising that (u8, u8) could just cohabit with
824
824
// u16 or even u32.
825
- let new_common_prim = match ( old_common_prim , prim) {
825
+ let new_prim = match ( old_prim , prim) {
826
826
// Allow all identical primitives.
827
- ( x, y) if x == y => Some ( x ) ,
827
+ ( x, y) if x == y => x ,
828
828
// Allow integers of the same size with differing signedness.
829
829
// We arbitrarily choose the signedness of the first variant.
830
- ( p @ Primitive :: Int ( x, _) , Primitive :: Int ( y, _) ) if x == y => Some ( p ) ,
830
+ ( p @ Primitive :: Int ( x, _) , Primitive :: Int ( y, _) ) if x == y => p ,
831
831
// Allow integers mixed with pointers of the same layout.
832
832
// We must represent this using a pointer, to avoid
833
833
// roundtripping pointers through ptrtoint/inttoptr.
834
834
( p @ Primitive :: Pointer ( _) , i @ Primitive :: Int ( ..) )
835
835
| ( i @ Primitive :: Int ( ..) , p @ Primitive :: Pointer ( _) )
836
836
if p. size ( dl) == i. size ( dl) && p. align ( dl) == i. align ( dl) =>
837
837
{
838
- Some ( p )
838
+ p
839
839
}
840
- _ => None ,
841
- } ;
842
- match new_common_prim {
843
- Some ( new_prim) => {
844
- // Primitives are compatible.
845
- // We may be updating the primitive here, for example from int->ptr.
846
- common_prim = Some ( ( new_prim, common_offset) ) ;
847
- }
848
- None => {
849
- // Primitives are incompatible.
840
+ _ => {
850
841
common_prim = None ;
851
842
break ;
852
843
}
853
- }
844
+ } ;
845
+ // We may be updating the primitive here, for example from int->ptr.
846
+ common_prim = Some ( ( new_prim, common_offset) ) ;
854
847
} else {
855
848
common_prim = Some ( ( prim, offset) ) ;
856
849
}
0 commit comments