Repository navigation
feat(ts): drop as std does in B-tree collects by a key's own Ord, max_by_key, and into_keys' ends - #499
Merged
Conversation
Quest-Claim: 84e6372f7bea4df6
…es that drop Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and min that drop 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>
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 still refused values that drop in three of std's iterator paths, the last ones left by quest/m3/ts-drop-order.md:
collectandfrominto a B-tree whose keys use their ownOrd,PartialOrd, orPartialEq, when the entries drop.max_by_keyandmin_by_keyby a key that drops.maxandminof aBTreeMap'sinto_keyswhen it holds something that drops.No moq consumer hits these at the pinned revision. The quest covers them because rust2 aims to support all of std.
Approach
rt.sliceSortports driftsort call for call, and a panic aborts on wasm32. So the existingrt.btreeCollectandrt.btreeCollectKeyspath (sort, then keep the last of each run!=finds equal, dropping the others key then value) already matches std. The refusal is gone.max_by_key/min_by_key: std reducesKeyAndValue { key, value }pairs. The runtime'sbestnow takesdropKey: a losing pair drops its key and then its item, and the winner's key drops once the fold ends.into_keysmax/min: std overrides both withnext_backandnext, and the rest of the entries drop with the iterator. The newrt.ownedEndreads that end and then disposes the iterator.orders(8 scenarios, differential against native wasm32), logs everycmp,partial_cmp,eq, key made, and drop. It covers sets and maps of keys whose impls disagree, sorts past std's insertion-sort cutoff,Cellkeys,fromarrays,max_by_keyandmin_by_key(including empty and single-item iterators),into_keysends, and a panic in the sort. Mutating the runtime (JS sort instead ofsliceSort, key dropped after its item, no dispose afterownedEnd) makes the step fail each time.ranked_cellsnow translates, so it is removed.Impact
rt.iterMaxByKeyandrt.iterMinByKeytakedropKeyafterowns, beforenone(added tots/MIGRATE.md).rt.ownedEnd(it, back, none?).Alternatives
Follow-ups
into_iter. Dropping a tree whole follows the runtime's key order, not std's node-by-node order, which the pinned nightly'sdrop_treenow walks in postorder. This was a maintainer decision on 2026-10-30 (ts/README.md), so no quest.Review
quest review, Codexgpt-6.1-solat medium effort, 3 rounds. The last round reviewed head3487cd55and reported no findings. The current head adds only a conflict-free merge of origin/main (#500), andjust cipasses on it.collections.rs:1351: a whole multi-node tree drops in key order, not in the nightly's postorderdrop_treeorder. Refuted: this is the maintainer's 2026-10-30 decision ints/README.md("Dropping a whole map or set drops its entries in the runtime's order...", #272). It applies to every dropping B-tree whatever its keys'Ord. The reviewer accepted this in round 2.🤖 Generated with Claude Code