-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with PartialEq
#67369
Comments
I simplified your example slightly to struct Foo<T: ?Sized> {
value: T,
}
impl<T: ?Sized> PartialEq for Foo<T> {
fn eq(&self, _: &Self) -> bool { true }
}
trait Trait {}
struct Bar {
ptr: Box<Foo<dyn Trait>>,
}
impl PartialEq for Bar {
fn eq(&self, other: &Self) -> bool {
self.ptr == other.ptr
}
}
fn main() {}
If you change Changing to |
It does work generically, even instantiated with the same type: // Foo and Trait as before
struct Bar<T: ?Sized> {
ptr: Box<Foo<T>>,
}
impl<T: ?Sized> PartialEq for Bar<T> {
fn eq(&self, other: &Self) -> bool {
self.ptr == other.ptr
}
}
fn eq(a: Bar<dyn Trait>, b: Bar<dyn Trait>) -> bool {
a == b
} |
I went nightly-bisecting -- it works on nightly-2015-05-13, and fails on 2015-05-14. Comparison: c2b30b8...e539424
That 1.0-compatible test source again: struct Foo<T: ?Sized> {
value: T,
}
impl<T: ?Sized> PartialEq for Foo<T> {
fn eq(&self, _: &Self) -> bool { true }
}
trait Trait {}
struct Bar {
ptr: Box<Foo<Trait>>,
}
impl PartialEq for Bar {
fn eq(&self, other: &Self) -> bool {
self.ptr == other.ptr
}
}
fn main() {} |
triage: no change |
When I try to
derive(PartialEq)
for type I get weird compilation error in generated code, but I'm sure it should be fine.Here's link to playground
The text was updated successfully, but these errors were encountered: