Repository navigation
feat(ts): translate == of hash maps and sets as std's - #543
Merged
Merged
Conversation
Quest-Claim: 6d48ccdf3947cf4f
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 3, 2026 19:25
|
This run was cancelled before it finished. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 23 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
==and!=of twoHashMaps or twoHashSets, std's or hashbrown's, were refused as an unsupported call, for aRandomStatemap too, and so was a derivedPartialEqof a type that holds one. Completes quest/m3/ts-hash-map-eq.md. No consumer yet; planned because rust2 aims to support all of std.Approach
rt.hashEq(eq?)does what std's and hashbrown'sPartialEqdo: equal lengths, then each entry ofselflooked up inother, andself's value==the one found. A set passes no valueeq.eq_fnmaps aHashMaporHashSetto it, so maps inside aVec, anOption, or a derivedPartialEqcompare too.eqof the key looked up by, given the held key, as hashbrown'sEquivalentdoes (self == key.borrow()). The runtime called the held key'seqinstead, which a loggingEqshowed for every lookup, not only map equality.BuildHasher, as feat(ts): hold a crate's own BuildHasher in a hash map or set #509 decided: the runtime never calls it, so maps whose hashers differ (seeded apart on each side) compare by their keys alone, as std's do.Tests, differential against native Rust:
lang/hasheshashes::equal: std maps and sets with a crateBuildHasherseeded apart on each side, of a key and value that log eachHashandeqwith the side they are on. Each compares both ways, against the same bytes in another order, all but the last, and one byte flipped. The crate hasher puts the key in hashbrown's tag bits so native callseqonly on the matching key; logs are written in call order for maps of at most one entry, sorted for equal maps, and dropped otherwise, as std's order decides which entries it visits before one differs. ThenRandomStatemaps of primitive and string keys, maps in aVec, and a derivedPartialEqholding a map and a set.stockmaps::equal: hashbrown's maps and sets with a crateBuildHasherseeded apart on each side, and the default hasher.eqorder failshashes::equal.Impact
rt.hashEqis new in the runtime; the translator's output for==/!=of hash maps and sets.eqrather than the held key's, matching std. No API change.Alternatives
slot's argument order and swap only inhashEq: leaves every other lookup calling the wrong side'seq.BuildHasherduring comparison: contradicts feat(ts): hold a crate's own BuildHasher in a hash map or set #509's hash-around decision, and lookups elsewhere don't.Follow-ups
BuildHasherDefault), left for its own PR.Review
Codex (
quest review), gpt-6.1-sol, medium effort, round 1 on8a32ee10d551546d8a5e330a4911e7c7719336f6: no findings.c4de918b992ed29e5b45f3f4a1705c58dc9a4fcaadds only conflict-free merges oforigin/mainon top, after whichjust cipassed.🤖 Generated with Claude Code