educe icon indicating copy to clipboard operation
educe copied to clipboard

Fix type inference failures in PartialOrd/Ord impls

Open sfackler opened this issue 9 months ago • 3 comments

Closes #36

sfackler avatar Feb 07 '25 15:02 sfackler

Uh, looking at this again, doesn't this comparison assume that the tag is at the start of the enum? I don't think that's guaranteed by anything.

If an enum has opted-in to having a primitive representation for its discriminant, then it’s possible to use pointers to read the memory location storing the discriminant. That cannot be done for enums using the default representation, however, as it’s undefined what layout the discriminant has and where it’s stored — it might not even be stored at all!

https://doc.rust-lang.org/stable/std/mem/fn.discriminant.html#accessing-the-numeric-value-of-the-discriminant

https://doc.rust-lang.org/stable/std/mem/fn.discriminant.html Should be the thing to use here.

sfackler avatar Feb 07 '25 15:02 sfackler

@magiclen do you have a chance to look at this? Experiencing breaks from this bug.

matthewbayer avatar Feb 19 '25 22:02 matthewbayer

+1 also experiencing bugs from this

jpcorreia99 avatar Aug 05 '25 11:08 jpcorreia99