File tree 1 file changed +18
-7
lines changed
1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -907,14 +907,25 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
907
907
let count = ( niche_variants. end ( ) . as_u32 ( )
908
908
- niche_variants. start ( ) . as_u32 ( )
909
909
+ 1 ) as u128 ;
910
- if let Some ( ( field_index, niche, ( niche_start, niche_scalar) ) ) = variants[ i]
911
- . iter ( )
912
- . enumerate ( )
913
- . filter_map ( |( i, & field) | {
914
- let niche = field. largest_niche . as_ref ( ) ?;
915
- Some ( ( i, niche, niche. reserve ( self , count) ?) )
910
+ let mut niche_size = 0 ;
911
+ if let Some ( ( field_index, niche, niche_start, niche_scalar) ) =
912
+ variants[ i] . iter ( ) . enumerate ( ) . fold ( None , |acc, ( j, & field) | {
913
+ let niche = match & field. largest_niche {
914
+ Some ( niche) => niche,
915
+ _ => return acc,
916
+ } ;
917
+ let ns = niche. available ( dl) ;
918
+ if ns <= niche_size {
919
+ return acc;
920
+ }
921
+ match niche. reserve ( self , count) {
922
+ Some ( pair) => {
923
+ niche_size = ns;
924
+ Some ( ( j, niche, pair. 0 , pair. 1 ) )
925
+ }
926
+ None => acc,
927
+ }
916
928
} )
917
- . max_by_key ( |( _, niche, _) | niche. available ( dl) )
918
929
{
919
930
let mut align = dl. aggregate_align ;
920
931
let st = variants
You can’t perform that action at this time.
0 commit comments