-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Switch #[derive(PartialEq)]
to have separate lhs and rhs lifetimes
#83957
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
Comments
@rustbot label: +C-bug |
The sole implementation of PartialEq for |
hmm, I had changed it to #[derive(PartialEq)]
pub enum MyItem<'a> {
Empty,
Thing(&'a [u8]),
} I'd expect to be able to compare two different instances of |
That produces #[automatically_derived]
#[allow(unused_qualifications)]
impl <'a> ::core::cmp::PartialEq for MyItem<'a> {
// ...
} So, I think #[automatically_derived]
#[allow(unused_qualifications)]
impl<'a, 'b> ::core::cmp::PartialEq<MyItem<'b>> for MyItem<'a> {
// ...
} |
I think whether two values that have different lifetimes can be considered equal or not is application-dependent. If, in your case, they are equal then you merely need implement |
Hmm, I'd argue that you'd have some field's impl<'lhs1, 'rhs1> PartialEq<Type<'rhs1>> for Type<'lhs1>
where
Field1<'lhs1>: PartialEq<Field1<'rhs1>>,
Field2<'lhs1>: PartialEq<Field2<'rhs1>>,
Field3<'lhs1>: PartialEq<Field3<'rhs1>>,
{
// ...
} |
#[derive(PartialEq)]
to have separate lhs and rhs lifetimes
@rustbot label: +A-lifetimes +A-macros -C-bug +C-enhancement +T-libs |
As far as I can tell the following code shouldn't cause a lifetime error but it does. If
Iter::Item
is changed to&'a ()
instead ofPhantomData<&'a ()>
the error goes away.(Playground)
Errors:
The text was updated successfully, but these errors were encountered: