diff options
Diffstat (limited to 'src/test/ui/cast/cast-as-bool.rs')
-rw-r--r-- | src/test/ui/cast/cast-as-bool.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/test/ui/cast/cast-as-bool.rs b/src/test/ui/cast/cast-as-bool.rs new file mode 100644 index 000000000..1aed218ae --- /dev/null +++ b/src/test/ui/cast/cast-as-bool.rs @@ -0,0 +1,9 @@ +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 +} |