Querify whether a type has structural equality (Take 2)#73066
Querify whether a type has structural equality (Take 2)#73066bors merged 3 commits intorust-lang:masterfrom
Conversation
|
(rust_highfive has picked a reviewer for you, use r? to override) |
|
r? @pnkfelix |
9dd072f to
9c1d643
Compare
9c1d643 to
38f6511
Compare
src/librustc_middle/ty/util.rs
Outdated
There was a problem hiding this comment.
The "total" comes from "totally ordered". Maybe this terminology doesn't extend to equality?
There was a problem hiding this comment.
I don't know what universally standard terminology is here, but in our own docs for PartialEq, the adjective "full" is used to differentiate, as in "full equivalence relation" versus "partial equivalence relation."
There was a problem hiding this comment.
(Or you could say "if equality for this type is both reflexive and structural", since the only thing differentiating an equivalence relation from a partial equivalence relation (PER) is whether the relation is reflexive.)
|
The perf improvement from this should be the same as #73021. |
There was a problem hiding this comment.
The type_marked_structural method is now only called from the has_structural_eq_impls query closure, right?
I think it would be better to make it non-pub in that case.
|
r=me. I'm not telling bors myself, because I want to give @ecstatic-morse a chance to see if they can make |
This helper method works for all types, falling back to a query for
`TyKind::Adt`s to determine whether the implement the
`{Partial,}StructuralEq` traits.
38f6511 to
2801761
Compare
|
📌 Commit 2801761 has been approved by |
…, r=pnkfelix Querify whether a type has structural equality (Take 2) Alternative to rust-lang#72177. Unlike in rust-lang#72177, this helper method works for all types, falling back to a query for `TyKind::Adt`s that determines whether the `{Partial,}StructuralEq` traits are implemented. This is my preferred interface for this method. I think this is better than just documenting that the helper only works for ADTs. If others disagree, we can just merge rust-lang#72177 with the fixes applied. This has already taken far too long.
Rollup of 8 pull requests Successful merges: - rust-lang#72932 (Clarify the behaviour of Pattern when used with methods like str::contains) - rust-lang#73066 (Querify whether a type has structural equality (Take 2)) - rust-lang#73194 (Prefer the associated constants for pattern matching error) - rust-lang#73241 (Add/update comments about MinGW late_link_args) - rust-lang#73267 (Use the built cargo for cargotest.) - rust-lang#73290 (Fix links when pinging notification groups) - rust-lang#73302 (Adjusted some doctests in libcore to use `should_panic`.) - rust-lang#73308 (pretty/asm.rs should only be tested for x86_64 and not AArch64) Failed merges: r? @ghost
Alternative to #72177.
Unlike in #72177, this helper method works for all types, falling back to a query for
TyKind::Adts that determines whether the{Partial,}StructuralEqtraits are implemented.This is my preferred interface for this method. I think this is better than just documenting that the helper only works for ADTs. If others disagree, we can just merge #72177 with the fixes applied. This has already taken far too long.