]> git.lizzy.rs Git - rust.git/blob - tests/ui/cmp_owned/without_suggestion.rs
Auto merge of #4478 - tsurai:master, r=flip1995
[rust.git] / tests / ui / cmp_owned / without_suggestion.rs
1 #[allow(clippy::unnecessary_operation)]
2
3 fn main() {
4     let x = &Baz;
5     let y = &Baz;
6     y.to_owned() == *x;
7
8     let x = &&Baz;
9     let y = &Baz;
10     y.to_owned() == **x;
11 }
12
13 struct Foo;
14
15 impl PartialEq for Foo {
16     fn eq(&self, other: &Self) -> bool {
17         self.to_owned() == *other
18     }
19 }
20
21 impl ToOwned for Foo {
22     type Owned = Bar;
23     fn to_owned(&self) -> Bar {
24         Bar
25     }
26 }
27
28 #[derive(PartialEq)]
29 struct Baz;
30
31 impl ToOwned for Baz {
32     type Owned = Baz;
33     fn to_owned(&self) -> Baz {
34         Baz
35     }
36 }
37
38 #[derive(PartialEq)]
39 struct Bar;
40
41 impl PartialEq<Foo> for Bar {
42     fn eq(&self, _: &Foo) -> bool {
43         true
44     }
45 }
46
47 impl std::borrow::Borrow<Foo> for Bar {
48     fn borrow(&self) -> &Foo {
49         static FOO: Foo = Foo;
50         &FOO
51     }
52 }