1- error[E0054]: cannot cast as `bool`
1+ error[E0054]: cannot cast `i32` as `bool`
22 --> $DIR/cast-as-bool.rs:2:13
33 |
44LL | let u = 5 as bool;
55 | ^^^^^^^^^ help: compare with zero instead: `5 != 0`
66
7- error[E0054]: cannot cast as `bool`
7+ error[E0054]: cannot cast `i32` as `bool`
88 --> $DIR/cast-as-bool.rs:6:13
99 |
1010LL | let t = (1 + 2) as bool;
1111 | ^^^^^^^^^^^^^^^ help: compare with zero instead: `(1 + 2) != 0`
1212
13- error[E0606 ]: casting `&'static str` as `bool` is invalid
13+ error[E0054 ]: cannot cast `u32` as `bool`
1414 --> $DIR/cast-as-bool.rs:10:13
1515 |
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+ |
1664LL | let v = "hello" as bool;
1765 | ^^^^^^^^^^^^^^^
1866 |
@@ -21,7 +69,7 @@ help: consider using the `is_empty` method on `&'static str` to determine if it
2169LL | let v = !"hello".is_empty();
2270 | + ~~~~~~~~~~~
2371
24- error: aborting due to 3 previous errors
72+ error: aborting due to 11 previous errors
2573
2674Some errors have detailed explanations: E0054, E0606.
2775For more information about an error, try `rustc --explain E0054`.
0 commit comments