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

Derived Hash impl is duck-typed #21160

Closed
apasel422 opened this issue Jan 14, 2015 · 3 comments · Fixed by #21161
Closed

Derived Hash impl is duck-typed #21160

apasel422 opened this issue Jan 14, 2015 · 3 comments · Fixed by #21161
Labels
P-medium Medium priority
Milestone

Comments

@apasel422
Copy link
Contributor

The following compiles successfully with rustc 1.0.0-nightly (170c4399e 2015-01-14 00:41:55 +0000):

struct Bar;
impl Bar {
    fn hash<T>(&self, _: T) {}
}
#[derive(Hash)]
struct Foo(Bar);

The derived code should probably use UFCS.

@apasel422
Copy link
Contributor Author

I'm working on a fix for this.

japaric pushed a commit to japaric/rust that referenced this issue Jan 14, 2015
expansion now uses `::std::hash::Hash::hash(&*__self_0_0, __arg_0)` instead of
`(*__self_0_0).hash(__arg_0)`

closes rust-lang#21160
@japaric
Copy link
Member

japaric commented Jan 14, 2015

fix in #21161

@apasel422 sorry, didn't see your message! I should've left a comment here

@apasel422
Copy link
Contributor Author

@japaric That's OK! Glad it's fixed. We should make sure the other deriving implementations don't suffer from the same problem.

@brson brson added P-medium Medium priority and removed I-nominated labels Jan 15, 2015
@brson brson added this to the 1.0 beta milestone Jan 15, 2015
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 15, 2015
expansion now uses `::std::hash::Hash::hash(&*__self_0_0, __arg_0)` instead of
`(*__self_0_0).hash(__arg_0)`

closes rust-lang#21160

r? @alexcrichton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-medium Medium priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants