summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_error_codes/src/error_codes/E0054.md
blob: c3eb375fbcc9a07e066a7af1ce3803346d81611c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
It is not allowed to cast to a bool.

Erroneous code example:

```compile_fail,E0054
let x = 5;

// Not allowed, won't compile
let x_is_nonzero = x as bool;
```

If you are trying to cast a numeric type to a bool, you can compare it with
zero instead:

```
let x = 5;

// Ok
let x_is_nonzero = x != 0;
```