From d065a499417e03ac8e3ab0f48aeddbe13741a2b4 Mon Sep 17 00:00:00 2001 From: varkor <github@varkor.com> Date: Tue, 16 Oct 2018 21:36:29 +0100 Subject: [PATCH] Nonempty arrays of uninhabited arrays are Abi::Uninhabited --- src/librustc/ty/layout.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 87d745e5cea..da3c00f5e08 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -551,13 +551,19 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { let size = element.size.checked_mul(count, dl) .ok_or(LayoutError::SizeOverflow(ty))?; + let abi = if size != Size::ZERO && ty.conservative_is_uninhabited(tcx) { + Abi::Uninhabited + } else { + Abi::Aggregate { sized: true } + }; + tcx.intern_layout(LayoutDetails { variants: Variants::Single { index: VariantIdx::new(0) }, fields: FieldPlacement::Array { stride: element.size, count }, - abi: Abi::Aggregate { sized: true }, + abi, align: element.align, size })