fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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