Open usamoi opened 2 years ago
The more I look at this, the more I'm realizing this is probably an edge case of the compiler inference rules. LANES
has nothing to do with the swizzle, yet the compiler is still selecting it as the expected vector width.
Here's a pared-down example that exhibits the same error, but without any swizzles at all:
#![feature(portable_simd)]
use std::simd::{Simd, SimdElement, LaneCount, SupportedLaneCount};
struct Outer<const UNRELATED_LANES: usize>;
impl<const UNRELATED_LANES: usize> Outer<UNRELATED_LANES>
where
LaneCount<UNRELATED_LANES>: SupportedLaneCount, // comment this line, and it compiles
{
fn test(x: Simd<usize, 4>) {
fn foo<T, const LANES: usize>(x: Simd<T, LANES>)
where
T: std::simd::SimdElement,
LaneCount<LANES>: SupportedLaneCount,
{
unimplemented!()
}
foo(x);
}
}
I tried this code:
I expected to see this happen: it compiles
Instead, this happened: it doesn't compile
Meta
rustc --version --verbose
: