]> git.lizzy.rs Git - rust.git/blob - tests/ui/cast/issue-106883-is-empty.rs
Rollup merge of #106906 - matthiaskrgr:clone, r=Nilstrieb
[rust.git] / tests / ui / cast / issue-106883-is-empty.rs
1 use std::ops::Deref;
2
3 struct Foo;
4
5 impl Deref for Foo {
6     type Target = [u8];
7
8     fn deref(&self) -> &Self::Target {
9         &[]
10     }
11 }
12
13 fn main() {
14     let _ = "foo" as bool;
15     //~^ ERROR casting `&'static str` as `bool` is invalid [E0606]
16
17     let _ = String::from("foo") as bool;
18     //~^ ERROR non-primitive cast: `String` as `bool` [E0605]
19
20     let _ = Foo as bool;
21     //~^ ERROR non-primitive cast: `Foo` as `bool` [E0605]
22 }
23
24 fn _slice(bar: &[i32]) -> bool {
25     bar as bool
26     //~^ ERROR casting `&[i32]` as `bool` is invalid [E0606]
27 }