Skip to content

Commit 0830650

Browse files
committed
Nonempty arrays of uninhabited arrays are Abi::Uninhabited
1 parent 6c235cf commit 0830650

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
@@ -555,13 +555,19 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
555555
let size = element.size.checked_mul(count, dl)
556556
.ok_or(LayoutError::SizeOverflow(ty))?;
557557

558+
let abi = if size != Size::ZERO && ty.conservative_is_uninhabited(tcx) {
559+
Abi::Uninhabited
560+
} else {
561+
Abi::Aggregate { sized: true }
562+
};
563+
558564
tcx.intern_layout(LayoutDetails {
559565
variants: Variants::Single { index: 0 },
560566
fields: FieldPlacement::Array {
561567
stride: element.size,
562568
count
563569
},
564-
abi: Abi::Aggregate { sized: true },
570+
abi,
565571
align: element.align,
566572
size
567573
})

0 commit comments

Comments
 (0)