]> git.lizzy.rs Git - rust.git/blob - tests/ui/stdlib-unit-tests/eq-multidispatch.rs
Rollup merge of #106797 - FawazTirmizi:dev/issues/104284, r=bjorn3
[rust.git] / tests / ui / stdlib-unit-tests / eq-multidispatch.rs
1 // run-pass
2
3 #[derive(PartialEq, Debug)]
4 struct Bar;
5 #[derive(Debug)]
6 struct Baz;
7 #[derive(Debug)]
8 struct Foo;
9 #[derive(Debug)]
10 struct Fu;
11
12 impl PartialEq for Baz { fn eq(&self, _: &Baz) -> bool  { true } }
13
14 impl PartialEq<Fu> for Foo { fn eq(&self, _: &Fu) -> bool { true } }
15 impl PartialEq<Foo> for Fu { fn eq(&self, _: &Foo) -> bool { true } }
16
17 impl PartialEq<Bar> for Foo { fn eq(&self, _: &Bar) -> bool { false } }
18 impl PartialEq<Foo> for Bar { fn eq(&self, _: &Foo) -> bool { false } }
19
20 fn main() {
21     assert!(Bar != Foo);
22     assert!(Foo != Bar);
23
24     assert_eq!(Bar, Bar);
25
26     assert_eq!(Baz, Baz);
27
28     assert_eq!(Foo, Fu);
29     assert_eq!(Fu, Foo);
30 }