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

Bad error with deriving(Eq) #11365

Closed
comex opened this issue Jan 7, 2014 · 1 comment
Closed

Bad error with deriving(Eq) #11365

comex opened this issue Jan 7, 2014 · 1 comment

Comments

@comex
Copy link
Contributor

comex commented Jan 7, 2014

This code is erroneous because A does not implement Eq:

struct A;
#[deriving(Eq)]
struct B(A);

However, trying to compile it produces two errors, one of which is nonsensical:

/tmp/z.rs:3:10: 3:12 error: mismatched types: expected `&&A` but found `&A` (expected &-ptr but found struct A)
/tmp/z.rs:3 struct B(A);
                     ^~
/tmp/z.rs:2:12: 2:14 note: in expansion of #[deriving(Eq)]
/tmp/z.rs:3:10: 3:12 note: expansion site
/tmp/z.rs:3:10: 3:12 error: failed to find an implementation of trait std::cmp::Eq for A
/tmp/z.rs:3 struct B(A);
                     ^~
/tmp/z.rs:2:12: 2:14 note: in expansion of #[deriving(Eq)]
/tmp/z.rs:3:10: 3:12 note: expansion site
task 'rustc' failed at 'explicit failure', /usr/src/rust/src/libsyntax/diagnostic.rs:41
task '<main>' failed at 'explicit failure', /usr/src/rust/src/librustc/lib.rs:440
@huonw
Copy link
Member

huonw commented Jan 7, 2014

Closing as a dupe of #7621. This is an unfortunate implementation detail that is required to get #[deriving] to work with types that move; I know approximately how to fix it and have attempted it, but I couldn't get the fix to actually work completely.

@huonw huonw closed this as completed Jan 7, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 8, 2024
`single_match`: fix checking of explicitly matched enums

fixes rust-lang#11365

This approach has false-negatives, but fixing them will require a significant amount of additional state tracking. The comment in `add_and_pats` has the explanation.

changelog: `single_match`: correct checking if the match explicitly matches all of an enum's variants.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants