1
- error[E0054]: cannot cast as `bool`
1
+ error[E0054]: cannot cast `i32` as `bool`
2
2
--> $DIR/cast-as-bool.rs:2:13
3
3
|
4
4
LL | let u = 5 as bool;
5
5
| ^^^^^^^^^ help: compare with zero instead: `5 != 0`
6
6
7
- error[E0054]: cannot cast as `bool`
7
+ error[E0054]: cannot cast `i32` as `bool`
8
8
--> $DIR/cast-as-bool.rs:6:13
9
9
|
10
10
LL | let t = (1 + 2) as bool;
11
11
| ^^^^^^^^^^^^^^^ help: compare with zero instead: `(1 + 2) != 0`
12
12
13
- error[E0606 ]: casting `&'static str` as `bool` is invalid
13
+ error[E0054 ]: cannot cast `u32` as `bool`
14
14
--> $DIR/cast-as-bool.rs:10:13
15
15
|
16
+ LL | let _ = 5_u32 as bool;
17
+ | ^^^^^^^^^^^^^ help: compare with zero instead: `5_u32 != 0`
18
+
19
+ error[E0054]: cannot cast `f64` as `bool`
20
+ --> $DIR/cast-as-bool.rs:13:13
21
+ |
22
+ LL | let _ = 64.0_f64 as bool;
23
+ | ^^^^^^^^^^^^^^^^ help: compare with zero instead: `64.0_f64 != 0`
24
+
25
+ error[E0054]: cannot cast `IntEnum` as `bool`
26
+ --> $DIR/cast-as-bool.rs:24:13
27
+ |
28
+ LL | let _ = IntEnum::One as bool;
29
+ | ^^^^^^^^^^^^^^^^^^^^ unsupported cast
30
+
31
+ error[E0054]: cannot cast `fn(u8) -> String {uwu}` as `bool`
32
+ --> $DIR/cast-as-bool.rs:33:13
33
+ |
34
+ LL | let _ = uwu as bool;
35
+ | ^^^^^^^^^^^ unsupported cast
36
+
37
+ error[E0054]: cannot cast `unsafe fn() {owo}` as `bool`
38
+ --> $DIR/cast-as-bool.rs:35:13
39
+ |
40
+ LL | let _ = owo as bool;
41
+ | ^^^^^^^^^^^ unsupported cast
42
+
43
+ error[E0054]: cannot cast `fn(u8) -> String` as `bool`
44
+ --> $DIR/cast-as-bool.rs:38:13
45
+ |
46
+ LL | let _ = uwu as fn(u8) -> String as bool;
47
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsupported cast
48
+
49
+ error[E0054]: cannot cast `char` as `bool`
50
+ --> $DIR/cast-as-bool.rs:40:13
51
+ |
52
+ LL | let _ = 'x' as bool;
53
+ | ^^^^^^^^^^^ unsupported cast
54
+
55
+ error[E0054]: cannot cast `*const ()` as `bool`
56
+ --> $DIR/cast-as-bool.rs:44:13
57
+ |
58
+ LL | let _ = ptr as bool;
59
+ | ^^^^^^^^^^^ unsupported cast
60
+
61
+ error[E0606]: casting `&'static str` as `bool` is invalid
62
+ --> $DIR/cast-as-bool.rs:46:13
63
+ |
16
64
LL | let v = "hello" as bool;
17
65
| ^^^^^^^^^^^^^^^
18
66
|
@@ -21,7 +69,7 @@ help: consider using the `is_empty` method on `&'static str` to determine if it
21
69
LL | let v = !"hello".is_empty();
22
70
| + ~~~~~~~~~~~
23
71
24
- error: aborting due to 3 previous errors
72
+ error: aborting due to 11 previous errors
25
73
26
74
Some errors have detailed explanations: E0054, E0606.
27
75
For more information about an error, try `rustc --explain E0054`.
0 commit comments