You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #882 (PR #1002) we used PartialEq analysis to analyse whether we can derive PartialOrd. Generally this makes sense because if PartialEq can be derived then PartialOrd can be derived too.
But there is a problem. I can imagine what means for opaque types to be PartialEq: we just have to compare byte-by-byte both blobs. But I have a problem imaging what we should do in case of PartialOrd: compare each byte in both blobs?
Maybe we should split result of the analysis and explicitly state whether we can derive PartialOrd or not?
The text was updated successfully, but these errors were encountered:
Writing this down I realized that it makes no sense to derive PartialEq for blobs either!
I'm not a compiler wizard, but isn't it is at least incorrect (if not UB) to compare byte-by-byte two structs because of stuff like padding bytes which, if I understand correctly, have undefined values.
Good point about padding. I guess we should only be "manually" implementing these things so that we don't look into padding.
Or I guess we could define a special type for padding that implements various traits with some kind of default/no-op that doesn't actually read the padding bits, and then we could still derive and the padding would effectively be skipped over.
This doesn't apply for opaque blobs of course.
@emilio if we stopped deriving traits for opaque things (except maybe Debug?), would that have bad implications for Stylo?
In #882 (PR #1002) we used
PartialEq
analysis to analyse whether we can derivePartialOrd
. Generally this makes sense because ifPartialEq
can be derived thenPartialOrd
can be derived too.But there is a problem. I can imagine what means for opaque types to be PartialEq: we just have to compare byte-by-byte both blobs. But I have a problem imaging what we should do in case of
PartialOrd
: compare each byte in both blobs?Maybe we should split result of the analysis and explicitly state whether we can derive PartialOrd or not?
The text was updated successfully, but these errors were encountered: