Skip to content
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

Regression in #[derive(Eq)] on type with non-Eq members. #36830

Closed
rphmeier opened this Issue Sep 29, 2016 · 13 comments

Comments

Projects
None yet
6 participants
@rphmeier
Copy link
Contributor

rphmeier commented Sep 29, 2016

Playground: https://play.rust-lang.org/?gist=ca6a481e640668153d66259c0ef1dde6&version=stable&backtrace=0

#[derive(Eq)]
pub struct Signature([u8; 65]);

impl PartialEq for Signature {
    fn eq(&self, other: &Self) -> bool {
        &self.0[..] == &other.0[..]
    }
}

fn main() { }

Succeeds on rustc 1.11.0 (9b21dcd6a 2016-08-15), but fails on rustc 1.13.0-beta.1 (cbbeba430 2016-09-28)

Seems to be related to std::cmp::AssertParamIsEq.

@bluss

This comment has been minimized.

Copy link
Contributor

bluss commented Sep 29, 2016

Caused by #36384

@bluss

This comment has been minimized.

Copy link
Contributor

bluss commented Sep 29, 2016

Explanation: previous ".assert_param_is_eq" used method resolution, finding slice methods on arrays. New code only looks at the type itself (the array).

cc @petrochenkov

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Sep 29, 2016

Theoretically, this is a bugfix, because the previous implementation didn't enforced the bounds properly.
However, I'm not sure if these restrictions on deriving Eq are necessary at all.

@bluss

This comment has been minimized.

Copy link
Contributor

bluss commented Sep 29, 2016

Without this road block, there would be many more Eq implementations on structs with floats in them.

@durka

This comment has been minimized.

Copy link
Contributor

durka commented Sep 29, 2016

Should maybe crater #36384 to see the "bugfix" impact.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Oct 3, 2016

Discussed during libs triage, conclusion was that we're likely to let this slide (as it's a bug fix) but we'll wait for the next crater build to ensure that no massive impact is seen.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Oct 7, 2016

Ok, ran crater, there are two regressions related to this

I believe the latter is yours, right @rphmeier? The former presumably hasn't been reported yet.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Oct 7, 2016

adding back the nominated tag to discuss again.

@rphmeier

This comment has been minimized.

Copy link
Contributor Author

rphmeier commented Oct 7, 2016

@alexcrichton right, I haven't published the fix to crates.io yet though.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Oct 10, 2016

Ok, the libs team discussed this today and the conclusion was that we can just send PRs to fix these issues.

@rphmeier to clarify have you got this fixed locally? If you need any help I can send a PR!

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Oct 10, 2016

@bluss holy cow thanks so much for sending a PR to fix xor_name!

@rphmeier

This comment has been minimized.

Copy link
Contributor Author

rphmeier commented Oct 10, 2016

@alexcrichton Yep, fixed in the repo, just haven't pushed the fix to crates.io yet. I'll try and do it tomorrow.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Oct 10, 2016

Ok, in that case I'm going to close this, thanks for the update though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.