]> git.lizzy.rs Git - rust.git/blob - tests/ui/traits/issue-26339.rs
Auto merge of #105716 - chriswailes:ndk-update-redux, r=pietroalbini
[rust.git] / tests / ui / traits / issue-26339.rs
1 // run-pass
2 // Test that the right implementation is called through a trait
3 // object when supertraits include multiple references to the
4 // same trait, with different type parameters.
5
6 trait A: PartialEq<Foo> + PartialEq<Bar> { }
7
8 struct Foo;
9 struct Bar;
10
11 struct Aimpl;
12
13 impl PartialEq<Foo> for Aimpl {
14     fn eq(&self, _rhs: &Foo) -> bool {
15         true
16     }
17 }
18
19 impl PartialEq<Bar> for Aimpl {
20     fn eq(&self, _rhs: &Bar) -> bool {
21         false
22     }
23 }
24
25 impl A for Aimpl { }
26
27 fn main() {
28     let a = &Aimpl as &dyn A;
29
30     assert!(*a == Foo);
31 }