Skip to content

Commit 0ab6ddd

Browse files
committed
Evaluate constants in SIMD vec lengths before rejecting them
1 parent b30d9eb commit 0ab6ddd

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

compiler/rustc_hir_analysis/src/check/intrinsicck.rs

+1
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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! This is a regression test to ensure that we evaluate
22
//! SIMD vector length constants instead of assuming they are literals.
33
4+
//@check-pass
5+
46
#![feature(repr_simd)]
57

68
const C: usize = 16;
@@ -13,7 +15,6 @@ pub unsafe fn foo(a: Foo) {
1315
std::arch::asm!(
1416
"movaps {src}, {src}",
1517
src = in(xmm_reg) a,
16-
//~^ ERROR: cannot use value of type `Foo` for inline assembly
1718
);
1819
}
1920

tests/ui/asm/named_const_simd_vec_len.stderr

-10
This file was deleted.

0 commit comments

Comments
 (0)