]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/cmp_owned/without_suggestion.rs
New upstream version 1.52.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / cmp_owned / without_suggestion.rs
CommitLineData
f20569fa
XL
1#[allow(clippy::unnecessary_operation)]
2#[allow(clippy::implicit_clone)]
3
4fn main() {
5 let x = &Baz;
6 let y = &Baz;
7 y.to_owned() == *x;
8
9 let x = &&Baz;
10 let y = &Baz;
11 y.to_owned() == **x;
12}
13
14struct Foo;
15
16impl PartialEq for Foo {
17 fn eq(&self, other: &Self) -> bool {
18 self.to_owned() == *other
19 }
20}
21
22impl ToOwned for Foo {
23 type Owned = Bar;
24 fn to_owned(&self) -> Bar {
25 Bar
26 }
27}
28
29#[derive(PartialEq)]
30struct Baz;
31
32impl ToOwned for Baz {
33 type Owned = Baz;
34 fn to_owned(&self) -> Baz {
35 Baz
36 }
37}
38
39#[derive(PartialEq)]
40struct Bar;
41
42impl PartialEq<Foo> for Bar {
43 fn eq(&self, _: &Foo) -> bool {
44 true
45 }
46}
47
48impl std::borrow::Borrow<Foo> for Bar {
49 fn borrow(&self) -> &Foo {
50 static FOO: Foo = Foo;
51 &FOO
52 }
53}