Skip to content

Commit 3448e3c

Browse files
Add E0512 error explanation
1 parent 95285c4 commit 3448e3c

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

src/librustc_trans/diagnostics.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,35 @@
1212

1313
register_long_diagnostics! {
1414

15+
E0512: r##"
16+
A transmute was called on types with different sizes. Erroneous code example:
17+
18+
```
19+
extern "rust-intrinsic" {
20+
pub fn ctpop8(x: u8) -> u8;
21+
}
22+
23+
fn main() {
24+
unsafe { ctpop8(::std::mem::transmute(0u16)); }
25+
// error: transmute called on types with different sizes
26+
}
27+
```
28+
29+
Please use types with same size or use the awaited type directly. Example:
30+
31+
```
32+
extern "rust-intrinsic" {
33+
pub fn ctpop8(x: u8) -> u8;
34+
}
35+
36+
fn main() {
37+
unsafe { ctpop8(::std::mem::transmute(0i8)); } // ok!
38+
// or:
39+
unsafe { ctpop8(0u8); } // ok!
40+
}
41+
```
42+
"##,
43+
1544
E0515: r##"
1645
A constant index expression was out of bounds. Erroneous code example:
1746
@@ -23,7 +52,7 @@ Please specify a valid index (not inferior to 0 or superior to array length).
2352
Example:
2453
2554
```
26-
let x = &[0, 1, 2][2]; // ok!
55+
let x = &[0, 1, 2][2]; // ok
2756
```
2857
"##,
2958

@@ -32,5 +61,4 @@ let x = &[0, 1, 2][2]; // ok!
3261
register_diagnostics! {
3362
E0510, // invalid use of `return_address` intrinsic: function does not use out pointer
3463
E0511, // invalid monomorphization of `{}` intrinsic
35-
E0512, // transmute called on types with potentially different sizes...
3664
}

0 commit comments

Comments
 (0)