Skip to content

Commit d065a49

Browse files
committed
Nonempty arrays of uninhabited arrays are Abi::Uninhabited
1 parent 419d2d8 commit d065a49

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/librustc/ty/layout.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,13 +551,19 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
551551
let size = element.size.checked_mul(count, dl)
552552
.ok_or(LayoutError::SizeOverflow(ty))?;
553553

554+
let abi = if size != Size::ZERO && ty.conservative_is_uninhabited(tcx) {
555+
Abi::Uninhabited
556+
} else {
557+
Abi::Aggregate { sized: true }
558+
};
559+
554560
tcx.intern_layout(LayoutDetails {
555561
variants: Variants::Single { index: VariantIdx::new(0) },
556562
fields: FieldPlacement::Array {
557563
stride: element.size,
558564
count
559565
},
560-
abi: Abi::Aggregate { sized: true },
566+
abi,
561567
align: element.align,
562568
size
563569
})

0 commit comments

Comments
 (0)