@@ -28,10 +28,11 @@ pub unsafe fn by_value() -> i32 {
28
28
}
29
29
```
30
30
31
- Returned values are stored in registers. In the case where the returned
32
- type doesn't fit in a register, the function returns `()` and has an
33
- additional input argument, this is a pointer where the result should
34
- be written. Example:
31
+ Return values may be stored in a return register(s) or written into a so-called
32
+ out pointer. In case the returned value is too big (this is
33
+ target-ABI-dependent and generally not portable or future proof) to fit into
34
+ the return register(s), the compiler will return the value by writing it into
35
+ space allocated in the caller's stack frame. Example:
35
36
36
37
```
37
38
extern "rust-intrinsic" {
@@ -45,8 +46,37 @@ pub unsafe fn by_pointer() -> String {
45
46
```
46
47
"## ,
47
48
49
+ E0511 : r##"
50
+ Invalid monomorphization of an intrinsic function was used. Erroneous code
51
+ example:
52
+
53
+ ```
54
+ extern "platform-intrinsic" {
55
+ fn simd_add<T>(a: T, b: T) -> T;
56
+ }
57
+
58
+ unsafe { simd_add(0, 1); }
59
+ // error: invalid monomorphization of `simd_add` intrinsic
60
+ ```
61
+
62
+ The generic type has to be a SIMD type. Example:
63
+
64
+ ```
65
+ #[repr(simd)]
66
+ #[derive(Copy, Clone)]
67
+ struct i32x1(i32);
68
+
69
+ extern "platform-intrinsic" {
70
+ fn simd_add<T>(a: T, b: T) -> T;
71
+ }
72
+
73
+ unsafe { simd_add(i32x1(0), i32x1(1)); } // ok!
74
+ ```
75
+ "## ,
76
+
48
77
E0512 : r##"
49
- A transmute was called on types with different sizes. Erroneous code example:
78
+ Transmute with two differently sized types was attempted. Erroneous code
79
+ example:
50
80
51
81
```
52
82
extern "rust-intrinsic" {
@@ -55,11 +85,11 @@ extern "rust-intrinsic" {
55
85
56
86
fn main() {
57
87
unsafe { ctpop8(::std::mem::transmute(0u16)); }
58
- // error: transmute called on types with different sizes
88
+ // error: transmute called with differently sized types
59
89
}
60
90
```
61
91
62
- Please use types with same size or use the awaited type directly. Example:
92
+ Please use types with same size or use the expected type directly. Example:
63
93
64
94
```
65
95
extern "rust-intrinsic" {
@@ -90,7 +120,3 @@ let x = &[0, 1, 2][2]; // ok
90
120
"## ,
91
121
92
122
}
93
-
94
- register_diagnostics ! {
95
- E0511 , // invalid monomorphization of `{}` intrinsic
96
- }
0 commit comments