Skip to content

Commit 11a7bad

Browse files
author
Nick Hamann
committed
Add long diagnostic for E0054
1 parent 11cb5e5 commit 11a7bad

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/librustc_typeck/diagnostics.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ methods that do not have default implementations), as well as any required
1919
trait items like associated types or constants.
2020
"##,
2121

22+
E0054: r##"
23+
It is not allowed to cast to a bool. If you are trying to cast a numeric type
24+
to a bool, you can compare it with zero instead:
25+
26+
```
27+
let x = 5;
28+
29+
// Ok
30+
let x_is_nonzero = x != 0;
31+
32+
// Not allowed, won't compile
33+
let x_is_nonzero = x as bool;
34+
```
35+
"##,
36+
2237
E0081: r##"
2338
Enum discriminants are used to differentiate enum variants stored in memory.
2439
This error indicates that the same value was used for two or more variants,
@@ -116,7 +131,6 @@ register_diagnostics! {
116131
E0049,
117132
E0050,
118133
E0053,
119-
E0054,
120134
E0055,
121135
E0057,
122136
E0059,

0 commit comments

Comments
 (0)