summaryrefslogtreecommitdiffstats
path: root/tests/ui/cast/cast-as-bool.stderr
blob: 4ff56a95e49a3db5080253d284b5c009784f6057 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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`.