@@ -542,14 +542,12 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
542
542
debug ! ( "univariant offset: {:?} field: {:#?}" , offset, field) ;
543
543
offsets[ i as usize ] = offset;
544
544
545
- if !repr. hide_niche ( ) {
546
- if let Some ( mut niche) = field. largest_niche {
547
- let available = niche. available ( dl) ;
548
- if available > largest_niche_available {
549
- largest_niche_available = available;
550
- niche. offset += offset;
551
- largest_niche = Some ( niche) ;
552
- }
545
+ if let Some ( mut niche) = field. largest_niche {
546
+ let available = niche. available ( dl) ;
547
+ if available > largest_niche_available {
548
+ largest_niche_available = available;
549
+ niche. offset += offset;
550
+ largest_niche = Some ( niche) ;
553
551
}
554
552
}
555
553
@@ -1104,23 +1102,29 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
1104
1102
assert ! ( valid_range. end >= end) ;
1105
1103
valid_range. end = end;
1106
1104
}
1107
-
1108
- // Update `largest_niche` if we have introduced a larger niche.
1109
- let niche = if def. repr ( ) . hide_niche ( ) {
1110
- None
1105
+ if def. is_unsafe_cell ( ) {
1106
+ match scalar {
1107
+ Scalar :: Initialized { value, valid_range } => {
1108
+ * valid_range = WrappingRange :: full ( value. size ( dl) )
1109
+ }
1110
+ // Already doesn't have any niches
1111
+ Scalar :: Union { .. } => { }
1112
+ }
1113
+ st. largest_niche = None ;
1111
1114
} else {
1112
- Niche :: from_scalar ( dl, Size :: ZERO , * scalar)
1113
- } ;
1114
- if let Some ( niche) = niche {
1115
- match st. largest_niche {
1116
- Some ( largest_niche) => {
1117
- // Replace the existing niche even if they're equal,
1118
- // because this one is at a lower offset.
1119
- if largest_niche. available ( dl) <= niche. available ( dl) {
1120
- st. largest_niche = Some ( niche) ;
1115
+ // Update `largest_niche` if we have introduced a larger niche.
1116
+ let niche = Niche :: from_scalar ( dl, Size :: ZERO , * scalar) ;
1117
+ if let Some ( niche) = niche {
1118
+ match st. largest_niche {
1119
+ Some ( largest_niche) => {
1120
+ // Replace the existing niche even if they're equal,
1121
+ // because this one is at a lower offset.
1122
+ if largest_niche. available ( dl) <= niche. available ( dl) {
1123
+ st. largest_niche = Some ( niche) ;
1124
+ }
1121
1125
}
1126
+ None => st. largest_niche = Some ( niche) ,
1122
1127
}
1123
- None => st. largest_niche = Some ( niche) ,
1124
1128
}
1125
1129
}
1126
1130
}
0 commit comments