Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upRFC 2235 - Implement PartialEq,Eq,Hash,Debug for all types #1217
Conversation
rust-highfive
assigned
alexcrichton
Jan 19, 2019
This comment has been minimized.
This comment has been minimized.
rust-highfive
commented
Jan 19, 2019
|
(rust_highfive has picked a reviewer for you, use r? to override) |
gnzlbg
reviewed
Jan 19, 2019
| @@ -27,6 +27,7 @@ default = ["use_std"] | |||
| use_std = [] | |||
| align = [] | |||
| rustc-dep-of-std = ['align', 'rustc-std-workspace-core'] | |||
| extra_traits = [] | |||
This comment has been minimized.
This comment has been minimized.
gnzlbg
Jan 19, 2019
•
Collaborator
We might want to start by using more fine grained features here (e.g. traits_eq), and having an extra_traits feature that enables them all.
gnzlbg
approved these changes
Jan 19, 2019
|
LGTM. I worry about the extra maintainability cost of the structs for which the traits cannot be derived automatically (because they contain arrays with more than 32 elements). Note: the style check is failing. |
This comment has been minimized.
This comment has been minimized.
I think so. |
Susurrus
force-pushed the
Susurrus:rfc_2235
branch
from
177a0a5
to
600b9c8
Jan 22, 2019
This comment has been minimized.
This comment has been minimized.
I'd prefer to not implement it like this. When we talk about maintainability costs, having more features is harder than less features. The RFC also had discussion about this, but I'd like to find out more about why it can't be done as the single trait as I've already implemented it before changing this to individual features.
Do you still have this concern after seeing the implementation? I'm uncertain what the maintainability cost will be that you're concerned about. There isn't much change to types after they're added to
I did this, though looking at the code I didn't see any types I manually implemented this for that would actually benefit from this. I still think it's the right call, as it may help in structs that haven't been added yet though. So I've completed implementing everything here, though there are some open questions on what to do for the fields that I skipped in my manual implementations. I'll see if they're trivial to implement manually or I'll ask if we can set guidelines such that some fields can be skipped to make things easier. |
gnzlbg
approved these changes
Jan 22, 2019
This comment has been minimized.
This comment has been minimized.
|
Oh, I see that the documentation build bots are still failing. Could you fix those? This error sounds familiar: cc @QuietMisdreavus
|
This comment has been minimized.
This comment has been minimized.
|
It looks like the Lines 16 to 17 in fb2b3da Maybe some kind of import for |
This comment has been minimized.
This comment has been minimized.
|
Actually, after digging into it, why are those doc builders still going if libc's docs are going to be hosted on docs.rs (which doesn't use |
This comment has been minimized.
This comment has been minimized.
|
That's a good question. I'd expect that |
This comment has been minimized.
This comment has been minimized.
|
I also wanted to ask about the |
This comment has been minimized.
This comment has been minimized.
|
I've also been thinking that we should probably have a test that checks that each type has the right extra traits. This will ensure any manually-implemented types won't miss traits they should have. But I don't know how to start that implementation; any ideas anyone? |
This comment has been minimized.
This comment has been minimized.
|
@Susurrus don't worry about the update to the
IMO the right way to do this is via a clippy lint. That is, we would have (or add) a lint to clippy, e.g., #![cfg_attr(feature = "cargo-clippy", deny(missing_debug_impl_on_public_items))]This lint will error if a public item does not implement #[cfg_attr(feature = "cargo-clippy", allow(missing_debug_impl_on_public_items))]
struct LookMaNoDebug;For every trait, we would need such a lint. You can open an issue about this in clippy upstream and cite this comment as motivation. Implementing such a lint is not hard, I can try to mentor you if you want, but clippy maintainers have a quick turnaround time and if you are in the Discord clippy channel they can tell you which existing lint you can base yours on to get it done quickly. FYI there is prior art of doing this. For example, in EDIT: one issue with this lint is that we would need to run clippy for all targets passing it the appropriate |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@gnzlbg Awesome idea using Clippy, didn't come to mind for me, but it makes a lot of sense. I've gone through Clippy and found the following:
So I've enabled some more lints and fixed some types that broke because of that as you'll see in the latest commits. |
This comment has been minimized.
This comment has been minimized.
alexcrichton
closed this
Jan 23, 2019
alexcrichton
reopened this
Jan 23, 2019
This comment has been minimized.
This comment has been minimized.
|
wrong button... |
This comment has been minimized.
This comment has been minimized.
|
This isn't ready for merging yet. When it is, I'll remove the WIP from the title of the PR. To catch everyone up on where this stands:
|
This comment has been minimized.
This comment has been minimized.
|
I would like some clarity on |
This comment has been minimized.
This comment has been minimized.
|
That is an artifact of when a |
Susurrus
force-pushed the
Susurrus:rfc_2235
branch
from
a401787
to
1f28bd7
Jan 23, 2019
Susurrus
force-pushed the
Susurrus:rfc_2235
branch
from
1f28bd7
to
130e5e1
Jan 23, 2019
This comment has been minimized.
This comment has been minimized.
|
Removed |
Susurrus
force-pushed the
Susurrus:rfc_2235
branch
from
130e5e1
to
0881a59
Jan 23, 2019
Susurrus
force-pushed the
Susurrus:rfc_2235
branch
from
c0b18fd
to
f631bdf
Jan 25, 2019
gnzlbg
reviewed
Jan 28, 2019
ci/run.sh Outdated
This comment has been minimized.
This comment has been minimized.
|
It appears that the lints and tests have uncovered a couple of issues (missing Copy impls, Debug impls that cannot be derived, etc.). |
Susurrus
force-pushed the
Susurrus:rfc_2235
branch
from
f631bdf
to
98c95b4
Jan 31, 2019
Susurrus
changed the title
RFC 2235 - Implement PartialEq,Eq,Hash,Debug for all types
WIP: RFC 2235 - Implement PartialEq,Eq,Hash,Debug for all types
Jan 31, 2019
Susurrus
force-pushed the
Susurrus:rfc_2235
branch
3 times, most recently
from
bc5fd6b
to
abf892f
Jan 31, 2019
This comment has been minimized.
This comment has been minimized.
|
I've been trying to figure out what to do with the The reason this comes up is because of the |
This comment has been minimized.
This comment has been minimized.
@gnzlbg coming back to this point, do you see this as a hard requirement. We're mostly covered by the |
Susurrus
force-pushed the
Susurrus:rfc_2235
branch
from
abf892f
to
c0081f0
Feb 2, 2019
This comment has been minimized.
This comment has been minimized.
|
Why use clippy? What's wrong with rustc's |
This comment has been minimized.
This comment has been minimized.
I'm already going with |
Susurrus
force-pushed the
Susurrus:rfc_2235
branch
2 times, most recently
from
a3e3140
to
c7196a6
Feb 2, 2019
Susurrus
added some commits
Jan 22, 2019
Susurrus
force-pushed the
Susurrus:rfc_2235
branch
2 times, most recently
from
921f966
to
4aef390
Feb 2, 2019
This comment has been minimized.
This comment has been minimized.
|
I think I've sorted everything out at this point. I probably need to do another visual run through of the complete diff, but it's shaping up nicely. Only blocker here is what to do about implementing I've also been making some headway with rust-lang/rust#58070 and might the desired lints for every trait we want done this weekend, but I don't think we'll want to block on that, since once it's merged it'll need to ride the train to stable. |
Susurrus
force-pushed the
Susurrus:rfc_2235
branch
from
4aef390
to
9865242
Feb 2, 2019
Susurrus
changed the title
WIP: RFC 2235 - Implement PartialEq,Eq,Hash,Debug for all types
RFC 2235 - Implement PartialEq,Eq,Hash,Debug for all types
Feb 2, 2019
This comment has been minimized.
This comment has been minimized.
|
Down to just |
Susurrus
added some commits
Jan 22, 2019
Susurrus
force-pushed the
Susurrus:rfc_2235
branch
from
9865242
to
e33f760
Feb 3, 2019
This comment has been minimized.
This comment has been minimized.
|
None of those failures seem related to my code, seem like CI problems. I figured out how to fix the problem I was talking about, so I think this is all ready for a merge. |
Susurrus commentedJan 19, 2019
•
edited
First pass at implementing RFC2235. I just started with
PartialEq/Eqand tested locally on my x64 Linux system. Definitely going to run into other types for other platforms that need this treatment, but thought I'd start small.Open question is whether this should also rely on the
alignfeature, which should improve which types can be auto-derived versus manually implemented (as it removed a lot of odd-sized padding arrays). My first pass here doesn't do that, but I might test it out to see if it does simplify quite a few structs. I think it might also be nice to have as it makes it easier for contributors to add new structs.Part of rust-lang/rust#57715