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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#![allow(non_snake_case)]
register_long_diagnostics! {
E0510: r##"
`return_address` was used in an invalid context. Erroneous code example:
```compile_fail
#![feature(intrinsics)]
extern "rust-intrinsic" {
fn return_address() -> *const u8;
}
unsafe fn by_value() -> i32 {
let _ = return_address();
// error: invalid use of `return_address` intrinsic: function does
// not use out pointer
0
}
```
Return values may be stored in a return register(s) or written into a so-called
out pointer. In case the returned value is too big (this is
target-ABI-dependent and generally not portable or future proof) to fit into
the return register(s), the compiler will return the value by writing it into
space allocated in the caller's stack frame. Example:
```
#![feature(intrinsics)]
extern "rust-intrinsic" {
fn return_address() -> *const u8;
}
unsafe fn by_pointer() -> String {
let _ = return_address();
String::new() // ok!
}
```
"##,
E0511: r##"
Invalid monomorphization of an intrinsic function was used. Erroneous code
example:
```compile_fail
#![feature(platform_intrinsics)]
extern "platform-intrinsic" {
fn simd_add<T>(a: T, b: T) -> T;
}
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(platform_intrinsics)]
#[repr(simd)]
#[derive(Copy, Clone)]
struct i32x1(i32);
extern "platform-intrinsic" {
fn simd_add<T>(a: T, b: T) -> T;
}
unsafe { simd_add(i32x1(0), i32x1(1)); } // ok!
```
"##,
}