about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
diff options
context:
space:
mode:
authorFabian Wolff <fabian.wolff@alumni.ethz.ch>2021-06-18 21:39:53 +0200
committerFabian Wolff <fabian.wolff@alumni.ethz.ch>2021-06-18 21:39:53 +0200
commite7a1186c6d4793a5265690dfd17fb05b15bf04ec (patch)
tree96c328b4131cad792cee6b88f16684a6a22912b5 /compiler/rustc_middle/src
parent312b894cc12240a3fcc645474c3daa14f7d568ea (diff)
downloadrust-e7a1186c6d4793a5265690dfd17fb05b15bf04ec.tar.gz
rust-e7a1186c6d4793a5265690dfd17fb05b15bf04ec.zip
Fix ICE with `#[repr(simd)]` on enum
Diffstat (limited to 'compiler/rustc_middle/src')
-rw-r--r--compiler/rustc_middle/src/ty/layout.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs
index 28a44b09de2..6b1ec1b0646 100644
--- a/compiler/rustc_middle/src/ty/layout.rs
+++ b/compiler/rustc_middle/src/ty/layout.rs
@@ -672,6 +672,15 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
 
             // SIMD vector types.
             ty::Adt(def, substs) if def.repr.simd() => {
+                if !def.is_struct() {
+                    // Should have yielded E0517 by now.
+                    tcx.sess.delay_span_bug(
+                        DUMMY_SP,
+                        "#[repr(simd)] was applied to an ADT that is not a struct",
+                    );
+                    return Err(LayoutError::Unknown(ty));
+                }
+
                 // Supported SIMD vectors are homogeneous ADTs with at least one field:
                 //
                 // * #[repr(simd)] struct S(T, T, T, T);