summaryrefslogtreecommitdiffstats
path: root/tests/ui/cast/cast-as-bool.rs
blob: fbebc80d91ced614a38fe76cf3acc64cf3313e9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
fn main() {
    let u = 5 as bool; //~ ERROR cannot cast as `bool`
                       //~| HELP compare with zero instead
                       //~| SUGGESTION 5 != 0

    let t = (1 + 2) as bool; //~ ERROR cannot cast as `bool`
                             //~| HELP compare with zero instead
                             //~| SUGGESTION (1 + 2) != 0

    let v = "hello" as bool;
    //~^ ERROR casting `&'static str` as `bool` is invalid
    //~| HELP consider using the `is_empty` method on `&'static str` to determine if it contains anything
}