Skip to content

Commit 84c1f11

Browse files
committed
Evaluate constants in SIMD vec lengths before rejecting them
1 parent c04b52a commit 84c1f11

File tree

3 files changed

+2
-11
lines changed

3 files changed

+2
-11
lines changed

compiler/rustc_hir_analysis/src/check/intrinsicck.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
8383

8484
let (size, ty) = match elem_ty.kind() {
8585
ty::Array(ty, len) => {
86+
let len = self.tcx.normalize_erasing_regions(self.typing_env, *len);
8687
if let Some(len) = len.try_to_target_usize(self.tcx) {
8788
(len, *ty)
8889
} else {

tests/ui/asm/named_const_simd_vec_len.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//! SIMD vector length constants instead of assuming they are literals.
33
44
//@ only-x86_64
5+
//@ check-pass
56

67
#![feature(repr_simd)]
78

@@ -15,7 +16,6 @@ pub unsafe fn foo(a: Foo) {
1516
std::arch::asm!(
1617
"movaps {src}, {src}",
1718
src = in(xmm_reg) a,
18-
//~^ ERROR: cannot use value of type `Foo` for inline assembly
1919
);
2020
}
2121

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +0,0 @@
1-
error: cannot use value of type `Foo` for inline assembly
2-
--> $DIR/named_const_simd_vec_len.rs:17:27
3-
|
4-
LL | src = in(xmm_reg) a,
5-
| ^
6-
|
7-
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
8-
9-
error: aborting due to 1 previous error
10-

0 commit comments

Comments
 (0)