rust/tests/ui/cast/cast-as-bool.stderr

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

96 lines
2.5 KiB
Plaintext
Raw Normal View History

2023-09-11 13:04:22 -05:00
error[E0054]: cannot cast `i32` as `bool`
2018-12-25 09:56:47 -06:00
--> $DIR/cast-as-bool.rs:2:13
|
2019-03-09 06:03:44 -06:00
LL | let u = 5 as bool;
2023-09-15 10:54:47 -05:00
| ^^^^^^^^^
|
help: compare with zero instead
|
LL | let u = 5 != 0;
| ~~~~
2023-09-11 13:04:22 -05:00
error[E0054]: cannot cast `i32` as `bool`
--> $DIR/cast-as-bool.rs:6:13
|
2019-03-09 06:03:44 -06:00
LL | let t = (1 + 2) as bool;
2023-09-15 10:54:47 -05:00
| ^^^^^^^^^^^^^^^
|
help: compare with zero instead
|
LL | let t = (1 + 2) != 0;
| ~~~~
2023-09-11 13:04:22 -05:00
error[E0054]: cannot cast `u32` as `bool`
--> $DIR/cast-as-bool.rs:10:13
|
2023-09-11 13:04:22 -05:00
LL | let _ = 5_u32 as bool;
2023-09-15 10:54:47 -05:00
| ^^^^^^^^^^^^^
|
help: compare with zero instead
|
LL | let _ = 5_u32 != 0;
| ~~~~
2023-09-11 13:04:22 -05:00
error[E0054]: cannot cast `f64` as `bool`
--> $DIR/cast-as-bool.rs:13:13
|
LL | let _ = 64.0_f64 as bool;
2023-09-15 10:54:47 -05:00
| ^^^^^^^^^^^^^^^^
|
help: compare with zero instead
|
LL | let _ = 64.0_f64 != 0;
| ~~~~
2023-09-11 13:04:22 -05:00
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
|
2019-03-09 06:03:44 -06:00
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();
| + ~~~~~~~~~~~
2023-09-11 13:04:22 -05:00
error: aborting due to 11 previous errors
Some errors have detailed explanations: E0054, E0606.
For more information about an error, try `rustc --explain E0054`.