about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-10-16 21:36:29 +0100
committervarkor <github@varkor.com>2018-12-11 11:18:55 +0000
commitd065a499417e03ac8e3ab0f48aeddbe13741a2b4 (patch)
treec015d104071bf1d3dde18eecdf4c39e803228290
parent419d2d8f319e30d4b8d071c10d427637056131a9 (diff)
downloadrust-d065a499417e03ac8e3ab0f48aeddbe13741a2b4.tar.gz
rust-d065a499417e03ac8e3ab0f48aeddbe13741a2b4.zip
Nonempty arrays of uninhabited arrays are Abi::Uninhabited
-rw-r--r--src/librustc/ty/layout.rs8
1 files changed, 7 insertions, 1 deletions
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
                 })