fork/rust

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

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

master
2.1 KiB58 linesraw
1error[E0606]: casting `&'static str` as `bool` is invalid
2  --> $DIR/issue-106883-is-empty.rs:14:13
3   |
4LL |     let _ = "foo" as bool;
5   |             ^^^^^^^^^^^^^
6   |
7help: consider using the `is_empty` method on `&'static str` to determine if it contains anything
8   |
9LL |     let _ = !"foo".is_empty();
10   |             +     ~~~~~~~~~~~
11
12error[E0605]: non-primitive cast: `String` as `bool`
13  --> $DIR/issue-106883-is-empty.rs:17:13
14   |
15LL |     let _ = String::from("foo") as bool;
16   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
17   |
18note: this expression `Deref`s to `str` which implements `is_empty`
19  --> $DIR/issue-106883-is-empty.rs:17:13
20   |
21LL |     let _ = String::from("foo") as bool;
22   |             ^^^^^^^^^^^^^^^^^^^
23help: consider using the `is_empty` method on `String` to determine if it contains anything
24   |
25LL |     let _ = !String::from("foo").is_empty();
26   |             +                   ~~~~~~~~~~~
27
28error[E0605]: non-primitive cast: `Foo` as `bool`
29  --> $DIR/issue-106883-is-empty.rs:20:13
30   |
31LL |     let _ = Foo as bool;
32   |             ^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
33   |
34note: this expression `Deref`s to `[u8]` which implements `is_empty`
35  --> $DIR/issue-106883-is-empty.rs:20:13
36   |
37LL |     let _ = Foo as bool;
38   |             ^^^
39help: consider using the `is_empty` method on `Foo` to determine if it contains anything
40   |
41LL |     let _ = !Foo.is_empty();
42   |             +   ~~~~~~~~~~~
43
44error[E0606]: casting `&[i32]` as `bool` is invalid
45  --> $DIR/issue-106883-is-empty.rs:25:5
46   |
47LL |     bar as bool
48   |     ^^^^^^^^^^^
49   |
50help: consider using the `is_empty` method on `&[i32]` to determine if it contains anything
51   |
52LL |     !bar.is_empty()
53   |     +   ~~~~~~~~~~~
54
55error: aborting due to 4 previous errors
56
57Some errors have detailed explanations: E0605, E0606.
58For more information about an error, try `rustc --explain E0605`.