//@[old]run-pass //@[generic_with_fn]run-pass //@ revisions: old generic generic_with_fn #![feature(repr_simd, intrinsics, adt_const_params, unsized_const_params, generic_const_exprs)] #![allow(incomplete_features)] extern "rust-intrinsic" { #[cfg(old)] fn simd_shuffle(a: T, b: T, i: I) -> U; #[cfg(any(generic, generic_with_fn))] fn simd_shuffle_generic(a: T, b: T) -> U; } #[derive(Copy, Clone)] #[repr(simd)] struct Simd([T; N]); trait Shuffle { const I: Simd; const J: &'static [u32] = &Self::I.0; unsafe fn shuffle(&self, a: Simd, b: Simd) -> Simd where Thing<{ Self::J }>:, { #[cfg(old)] return simd_shuffle(a, b, Self::I); #[cfg(generic)] return simd_shuffle_generic::<_, _, { &Self::I.0 }>(a, b); //[generic]~^ overly complex generic constant #[cfg(generic_with_fn)] return simd_shuffle_generic::<_, _, { Self::J }>(a, b); } } struct Thing; fn main() { struct I1; impl Shuffle<4> for I1 { const I: Simd = Simd([0, 2, 4, 6]); } struct I2; impl Shuffle<2> for I2 { const I: Simd = Simd([1, 5]); } let a = Simd::([0, 1, 2, 3]); let b = Simd::([4, 5, 6, 7]); unsafe { let x: Simd = I1.shuffle(a, b); assert_eq!(x.0, [0, 2, 4, 6]); let y: Simd = I2.shuffle(a, b); assert_eq!(y.0, [1, 5]); } }