Closed
Description
In the following test case, rustc selects the second implementation instead of the first one :
trait A : PartialEq<Foo> + PartialEq<Bar> { }
struct Foo;
struct Bar;
struct Aimpl;
impl PartialEq<Foo> for Aimpl {
fn eq(&self, _rhs: &Foo) -> bool {
panic!("Compare with foo")
}
}
impl PartialEq<Bar> for Aimpl {
fn eq(&self, _rhs: &Bar) -> bool {
panic!("Compare with bar")
}
}
impl A for Aimpl { }
fn main() {
let a = &Aimpl as &A;
*a == Foo;
}
This can lead to uninitialised memory access. Thanks to bluss for further reducing the testcase.