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)
This commit is contained in:
commit
bae53a7c3c
4 changed files with 38 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue