]> git.lizzy.rs Git - rust.git/blob - src/test/ui/simd/intrinsic/generic-select.rs
Stabilize File::options()
[rust.git] / src / test / ui / simd / intrinsic / generic-select.rs
1 // build-fail
2
3 // Test that the simd_select intrinsic produces ok-ish error
4 // messages when misused.
5
6 #![feature(repr_simd, platform_intrinsics)]
7 #![allow(non_camel_case_types)]
8
9 #[repr(simd)]
10 #[derive(Copy, Clone)]
11 pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
12
13 #[repr(simd)]
14 #[derive(Copy, Clone)]
15 pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
16
17 #[repr(simd)]
18 #[derive(Copy, Clone, PartialEq)]
19 struct b8x4(pub i8, pub i8, pub i8, pub i8);
20
21 #[repr(simd)]
22 #[derive(Copy, Clone, PartialEq)]
23 struct b8x8(pub i8, pub i8, pub i8, pub i8,
24             pub i8, pub i8, pub i8, pub i8);
25
26 extern "platform-intrinsic" {
27     fn simd_select<T, U>(x: T, a: U, b: U) -> U;
28     fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U;
29 }
30
31 fn main() {
32     let m4 = b8x4(0, 0, 0, 0);
33     let m8 = b8x8(0, 0, 0, 0, 0, 0, 0, 0);
34     let x = u32x4(0, 0, 0, 0);
35     let z = f32x4(0.0, 0.0, 0.0, 0.0);
36
37     unsafe {
38         simd_select(m4, x, x);
39
40         simd_select(m8, x, x);
41         //~^ ERROR mismatched lengths: mask length `8` != other vector length `4`
42
43         simd_select(x, x, x);
44         //~^ ERROR mask element type is `u32`, expected `i_`
45
46         simd_select(z, z, z);
47         //~^ ERROR mask element type is `f32`, expected `i_`
48
49         simd_select(m4, 0u32, 1u32);
50         //~^ ERROR found non-SIMD `u32`
51
52         simd_select_bitmask(0u16, x, x);
53         //~^ ERROR mask length `16` != other vector length `4`
54         //
55         simd_select_bitmask(0u8, 1u32, 2u32);
56         //~^ ERROR found non-SIMD `u32`
57
58         simd_select_bitmask(0.0f32, x, x);
59         //~^ ERROR `f32` is not an integral type
60
61         simd_select_bitmask("x", x, x);
62         //~^ ERROR `&str` is not an integral type
63     }
64 }