mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
96 lines
2.5 KiB
Plaintext
96 lines
2.5 KiB
Plaintext
error[E0054]: cannot cast `i32` as `bool`
|
|
--> $DIR/cast-as-bool.rs:2:13
|
|
|
|
|
LL | let u = 5 as bool;
|
|
| ^^^^^^^^^
|
|
|
|
|
help: compare with zero instead
|
|
|
|
|
LL | let u = 5 != 0;
|
|
| ~~~~
|
|
|
|
error[E0054]: cannot cast `i32` as `bool`
|
|
--> $DIR/cast-as-bool.rs:6:13
|
|
|
|
|
LL | let t = (1 + 2) as bool;
|
|
| ^^^^^^^^^^^^^^^
|
|
|
|
|
help: compare with zero instead
|
|
|
|
|
LL | let t = (1 + 2) != 0;
|
|
| ~~~~
|
|
|
|
error[E0054]: cannot cast `u32` as `bool`
|
|
--> $DIR/cast-as-bool.rs:10:13
|
|
|
|
|
LL | let _ = 5_u32 as bool;
|
|
| ^^^^^^^^^^^^^
|
|
|
|
|
help: compare with zero instead
|
|
|
|
|
LL | let _ = 5_u32 != 0;
|
|
| ~~~~
|
|
|
|
error[E0054]: cannot cast `f64` as `bool`
|
|
--> $DIR/cast-as-bool.rs:13:13
|
|
|
|
|
LL | let _ = 64.0_f64 as bool;
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
|
help: compare with zero instead
|
|
|
|
|
LL | let _ = 64.0_f64 != 0;
|
|
| ~~~~
|
|
|
|
error[E0054]: cannot cast `IntEnum` as `bool`
|
|
--> $DIR/cast-as-bool.rs:24:13
|
|
|
|
|
LL | let _ = IntEnum::One as bool;
|
|
| ^^^^^^^^^^^^^^^^^^^^ unsupported cast
|
|
|
|
error[E0054]: cannot cast `fn(u8) -> String {uwu}` as `bool`
|
|
--> $DIR/cast-as-bool.rs:33:13
|
|
|
|
|
LL | let _ = uwu as bool;
|
|
| ^^^^^^^^^^^ unsupported cast
|
|
|
|
error[E0054]: cannot cast `unsafe fn() {owo}` as `bool`
|
|
--> $DIR/cast-as-bool.rs:35:13
|
|
|
|
|
LL | let _ = owo as bool;
|
|
| ^^^^^^^^^^^ unsupported cast
|
|
|
|
error[E0054]: cannot cast `fn(u8) -> String` as `bool`
|
|
--> $DIR/cast-as-bool.rs:38:13
|
|
|
|
|
LL | let _ = uwu as fn(u8) -> String as bool;
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsupported cast
|
|
|
|
error[E0054]: cannot cast `char` as `bool`
|
|
--> $DIR/cast-as-bool.rs:40:13
|
|
|
|
|
LL | let _ = 'x' as bool;
|
|
| ^^^^^^^^^^^ unsupported cast
|
|
|
|
error[E0054]: cannot cast `*const ()` as `bool`
|
|
--> $DIR/cast-as-bool.rs:44:13
|
|
|
|
|
LL | let _ = ptr as bool;
|
|
| ^^^^^^^^^^^ unsupported cast
|
|
|
|
error[E0606]: casting `&'static str` as `bool` is invalid
|
|
--> $DIR/cast-as-bool.rs:46:13
|
|
|
|
|
LL | let v = "hello" as bool;
|
|
| ^^^^^^^^^^^^^^^
|
|
|
|
|
help: consider using the `is_empty` method on `&'static str` to determine if it contains anything
|
|
|
|
|
LL | let v = !"hello".is_empty();
|
|
| + ~~~~~~~~~~~
|
|
|
|
error: aborting due to 11 previous errors
|
|
|
|
Some errors have detailed explanations: E0054, E0606.
|
|
For more information about an error, try `rustc --explain E0054`.
|