about summary refs log tree commit diff
path: root/compiler/rustc_error_codes/src/error_codes/E0511.md
blob: 0fb1cfda67dc6903790ead8b36f2a7b625a9d205 (plain)
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
Invalid monomorphization of an intrinsic function was used.

Erroneous code example:

```compile_fail,E0511
#![feature(intrinsics)]

#[rustc_intrinsic]
unsafe fn simd_add<T>(a: T, b: T) -> T;

fn main() {
    unsafe { simd_add(0, 1); }
    // error: invalid monomorphization of `simd_add` intrinsic
}
```

The generic type has to be a SIMD type. Example:

```
#![feature(repr_simd)]
#![feature(intrinsics)]

#[repr(simd)]
#[derive(Copy, Clone)]
struct i32x2([i32; 2]);

#[rustc_intrinsic]
unsafe fn simd_add<T>(a: T, b: T) -> T;

unsafe { simd_add(i32x2([0, 0]), i32x2([1, 2])); } // ok!
```