File: generic-shuffle.rs

package info (click to toggle)
rustc-web 1.78.0%2Bdfsg1-2~deb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,245,420 kB
  • sloc: xml: 147,985; javascript: 18,022; sh: 11,083; python: 10,265; ansic: 6,172; cpp: 5,023; asm: 4,390; makefile: 4,269
file content (33 lines) | stat: -rw-r--r-- 873 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//@ build-fail

// Test that the simd_shuffle intrinsic produces ok-ish error
// messages when misused.

#![feature(repr_simd, intrinsics)]

#[repr(simd)]
#[derive(Copy, Clone)]
pub struct Simd<T, const N: usize>([T; N]);

extern "rust-intrinsic" {
    fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U;
}

fn main() {
    const I: [u32; 2] = [0; 2];
    const I2: [f32; 2] = [0.; 2];
    let v = Simd::<u32, 4>([0; 4]);

    unsafe {
        let _: Simd<u32, 2> = simd_shuffle(v, v, I);

        let _: Simd<u32, 4> = simd_shuffle(v, v, I);
        //~^ ERROR invalid monomorphization of `simd_shuffle` intrinsic

        let _: Simd<f32, 2> = simd_shuffle(v, v, I);
        //~^ ERROR invalid monomorphization of `simd_shuffle` intrinsic

        let _: Simd<u32, 2> = simd_shuffle(v, v, I2);
        //~^ ERROR invalid monomorphization of `simd_shuffle` intrinsic
    }
}