Repository navigation
feat(ts): translate BuildHasherDefault as a value that holds nothing - #544
Merged
Merged
Conversation
Quest-Claim: 82c10d747866d9d8
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…thing 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:56
|
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 54 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
rust2-ts refused
BuildHasherDefault<H>, std'sBuildHasherof aDefaultHasher, which is howrustc-hash'sFxHashMapandnohash-hasher'sIntMapbuild theirs: "unsupported typestd::hash::BuildHasherDefaultfrom another crate". Quest:quest/m3/ts-build-hasher-default.md(all of std; no moq consumer yet).Approach
BuildHasherDefaultholds only aPhantomData, so it joinslibrary::nothing: its value isundefined, made bynew,Default,Clone, a constant, or an aggregate, every value==, and itsDebugwritesBuildHasherDefault, as std'sdebug_struct(..).finish()does.build_hasherisH::default().hash_onebuilds that, hashes, finishes, and drops the hasher then the value: through the crate's ownHas feat(ts): hold a crate's own BuildHasher in a hash map or set #509'sown_hash_onedoes, or std'sDefaultHasherasRandomState's does.hasherlendsundefined, which hashes throughHas above.const partthat nothing read onceDebugignored it, whichtscrefuses (also forPhantomData, e.g.format!("{:?}", &pair.1)). Such a reference is nowundefinedin place. A&mutis left alone, as it may be anrt.Place.Tests, differential against native Rust:
lang/hasheshashes::defaults: a loggingHasher(Tally) behindBuildHasherDefault:new,Default,Clone, aconst,==/!=,Debug({:?},{:#?}, insideOption), a struct derivingDefault/Clone/Debug/PartialEqover it,build_hasher, andhash_oneof several key kinds, logging eachDefault, write, finish, and drop. Then stdHashMap/HashSetoverBuildHasherDefault<Fnv>:default,with_capacity_and_hasher, entry API, lookups,hasher().hash_one,clone,collect,|,is_subset.stockmaps::default_hasher: hashbrown maps overBuildHasherDefault<DefaultHasher>, whosehasher().hash_onemust matchDefaultHasher::newbyte for byte, and their==.==of a map overBuildHasherDefaultagainst its clone, now that feat(ts): translate == of hash maps and sets as std's #543 has landed.lang/cells,lang/results,lang/shapes: a shared&()or&..part now reads asundefinedin place (for examplef(self)becomesf(undefined)).Impact
BuildHasherDefault<H>translates asundefined. No public API change.Alternatives
library, so this followsRandomStateandPhantomData.held_statereturningNonefor a nothing state: changes how maps pick their key hasher; keeping it held needs no special case.Follow-ups
Review
quest review, gpt-6.1-sol, medium effort.rt/collections.ts:474's lookup-keyeqreceiver, which this branch never touched; the base already had feat(ts): translate == of hash maps and sets as std's #543 and the branch hadn't merged it yet. Merged since;git diff origin/main...HEAD -- ts/runtimeis empty.just cipassed on it.🤖 Generated with Claude Code