Skip to content

Commit a71e0be

Browse files
authored
Unrolled build for rust-lang#135295
Rollup merge of rust-lang#135295 - eyraudh:master, r=compiler-errors Check empty SIMD vector in inline asm fixes [rust-lang#134334](rust-lang#134334)
2 parents 70dab5a + ff699ce commit a71e0be

File tree

4 files changed

+38
-9
lines changed

4 files changed

+38
-9
lines changed

compiler/rustc_hir_analysis/src/check/intrinsicck.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ enum NonAsmTypeReason<'tcx> {
2929
Invalid(Ty<'tcx>),
3030
InvalidElement(DefId, Ty<'tcx>),
3131
NotSizedPtr(Ty<'tcx>),
32+
EmptySIMDArray(Ty<'tcx>),
3233
}
3334

3435
impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
@@ -102,6 +103,9 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
102103
}
103104
ty::Adt(adt, args) if adt.repr().simd() => {
104105
let fields = &adt.non_enum_variant().fields;
106+
if fields.is_empty() {
107+
return Err(NonAsmTypeReason::EmptySIMDArray(ty));
108+
}
105109
let field = &fields[FieldIdx::ZERO];
106110
let elem_ty = field.ty(self.tcx(), args);
107111

@@ -226,6 +230,10 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
226230
can be used as arguments for inline assembly",
227231
).emit();
228232
}
233+
NonAsmTypeReason::EmptySIMDArray(ty) => {
234+
let msg = format!("use of empty SIMD vector `{ty}`");
235+
self.infcx.dcx().struct_span_err(expr.span, msg).emit();
236+
}
229237
}
230238
return None;
231239
}

tests/crashes/134334.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Regression test for issue #134224.
2+
//@ only-x86_64
3+
4+
#![feature(repr_simd)]
5+
6+
#[repr(simd)]
7+
struct A();
8+
//~^ ERROR SIMD vector cannot be empty
9+
10+
fn main() {
11+
unsafe {
12+
std::arch::asm!("{}", in(xmm_reg) A());
13+
//~^ use of empty SIMD vector `A`
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0075]: SIMD vector cannot be empty
2+
--> $DIR/empty-simd-vector-in-operand.rs:7:1
3+
|
4+
LL | struct A();
5+
| ^^^^^^^^
6+
7+
error: use of empty SIMD vector `A`
8+
--> $DIR/empty-simd-vector-in-operand.rs:12:43
9+
|
10+
LL | std::arch::asm!("{}", in(xmm_reg) A());
11+
| ^^^
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0075`.

0 commit comments

Comments
 (0)