about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-04-02 13:10:36 +1100
committerGitHub <noreply@github.com>2025-04-02 13:10:36 +1100
commitbae53a7c3cc5a070e9301da1f3586da01a52bfca (patch)
treef715aeec0c1ffb4795521b4330cb9e1971ee2e1e /compiler
parent9b7d5ac8180f70110e94f92ccbf8fa2263d24c73 (diff)
parentff699ce9f55e974e9181a800203fae9d73b90e37 (diff)
downloadrust-bae53a7c3cc5a070e9301da1f3586da01a52bfca.tar.gz
rust-bae53a7c3cc5a070e9301da1f3586da01a52bfca.zip
Rollup merge of #135295 - eyraudh:master, r=compiler-errors
Check empty SIMD vector in inline asm

fixes [#134334](https://github.com/rust-lang/rust/issues/134334)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_analysis/src/check/intrinsicck.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs
index d63165f0f16..32a582aadc1 100644
--- a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs
+++ b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs
@@ -29,6 +29,7 @@ enum NonAsmTypeReason<'tcx> {
     Invalid(Ty<'tcx>),
     InvalidElement(DefId, Ty<'tcx>),
     NotSizedPtr(Ty<'tcx>),
+    EmptySIMDArray(Ty<'tcx>),
 }
 
 impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
@@ -102,6 +103,9 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
             }
             ty::Adt(adt, args) if adt.repr().simd() => {
                 let fields = &adt.non_enum_variant().fields;
+                if fields.is_empty() {
+                    return Err(NonAsmTypeReason::EmptySIMDArray(ty));
+                }
                 let field = &fields[FieldIdx::ZERO];
                 let elem_ty = field.ty(self.tcx(), args);
 
@@ -226,6 +230,10 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
                             can be used as arguments for inline assembly",
                         ).emit();
                     }
+                    NonAsmTypeReason::EmptySIMDArray(ty) => {
+                        let msg = format!("use of empty SIMD vector `{ty}`");
+                        self.infcx.dcx().struct_span_err(expr.span, msg).emit();
+                    }
                 }
                 return None;
             }