Skip to content

Commit 4618aad

Browse files
Add E0511 error explanation
1 parent 0836a6f commit 4618aad

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

src/librustc_trans/diagnostics.rs

+37-11
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ pub unsafe fn by_value() -> i32 {
2828
}
2929
```
3030
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:
3536
3637
```
3738
extern "rust-intrinsic" {
@@ -45,8 +46,37 @@ pub unsafe fn by_pointer() -> String {
4546
```
4647
"##,
4748

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+
4877
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:
5080
5181
```
5282
extern "rust-intrinsic" {
@@ -55,11 +85,11 @@ extern "rust-intrinsic" {
5585
5686
fn main() {
5787
unsafe { ctpop8(::std::mem::transmute(0u16)); }
58-
// error: transmute called on types with different sizes
88+
// error: transmute called with differently sized types
5989
}
6090
```
6191
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:
6393
6494
```
6595
extern "rust-intrinsic" {
@@ -90,7 +120,3 @@ let x = &[0, 1, 2][2]; // ok
90120
"##,
91121

92122
}
93-
94-
register_diagnostics! {
95-
E0511, // invalid monomorphization of `{}` intrinsic
96-
}

0 commit comments

Comments
 (0)