Repository navigation
feat(ts): split a deque's slices where std's are, and translate their Debug #443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d5427f9
chore(quest): claim quest/m3/ts-deque-slices.md
kixelated b33b14f
feat(ts): split a deque's slices where std's are, and translate their…
kixelated 26bc85d
Merge remote-tracking branch 'origin/main' into quest/m3/ts-deque-slices
kixelated 51ec109
style(ts): format
kixelated 6a6c21b
fix(ts): clone a deque into another by its clone_from
kixelated a23e4fa
test(ts): refresh the snapshots of deques' new arguments
kixelated 4389572
fix(ts): collect a byte vector's iterator into a deque with its capacity
kixelated 742d225
Merge remote-tracking branch 'origin/main' into quest/m3/ts-deque-slices
kixelated 21de74b
test(ts): refresh the harness snapshot after merging main
kixelated fb531cc
fix(ts): clone a vector's iterator into a buffer of its own
kixelated b202d7b
Merge remote-tracking branch 'origin/main' into quest/m3/ts-deque-slices
kixelated 6496e0b
Merge remote-tracking branch 'origin/main' into quest/m3/ts-deque-slices
kixelated 577eef4
feat(ts): keep std's Vec capacity where it reuses a buffer
kixelated 49ef58a
Merge remote-tracking branch 'origin/main' into quest/m3/ts-deque-slices
kixelated 5573882
chore(ts): update snapshots for the merge
kixelated 1b056aa
Merge remote-tracking branch 'origin/main' into quest/m3/ts-deque-slices
kixelated File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # [S] A comparison of two constants | ||
|
|
||
| ## Goal | ||
|
|
||
| [rust2-ts](/ts/README.md) translates a comparison whose sides are both constants once a | ||
| generic function is monomorphized, such as `size_of::<T>() == 1` in a function generic | ||
| over `T`, into TypeScript `tsc` accepts, proven by a fixture that runs it for a `T` of each | ||
| outcome against native Rust. | ||
|
|
||
| ## Plan | ||
|
|
||
| Found writing the deque's slices fixture | ||
| ([moq-dev/rust2#443](https://github.com/moq-dev/rust2/pull/443)): each instance writes | ||
| `12 === 1`, which `tsc` rejects as TS2367, two literal types with no overlap, so the | ||
| crate fails to translate. Fold the comparison to its value, or widen a side, where both are | ||
| literals. | ||
|
|
||
| Public API: the translator's output. |
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # [M] A vector's exact capacity as it shrinks | ||
|
|
||
| ## Goal | ||
|
|
||
| [rust2-ts](/ts/README.md) holds a `Vec`'s exact capacity through every step, as it now | ||
| does a `VecDeque`'s, so a deque made from a `Vec` splits its slices where std's does, | ||
| proven by differential tests against native Rust. | ||
|
|
||
| ## Plan | ||
|
|
||
| Found splitting a deque's slices where std's does | ||
| ([moq-dev/rust2#443](https://github.com/moq-dev/rust2/pull/443)): a deque now holds std's | ||
| exact capacity, but one made from a `Vec`, by `From<Vec<T>>` or by `collect`, takes the | ||
| capacity the runtime models for the `Vec`, which holds only std's guarantees (decided | ||
| 2026-11-01) and so recomputes from its length after a pop, `truncate`, or `drain`. A | ||
| `Vec<u8>` already holds its exact capacity as its buffer's length. | ||
|
|
||
| - Recording the capacity on the array where a step shrinks the length (a `peak` each pop | ||
| raises) was measured on `push/stack`, which pushes onto a `Vec`, popping one every | ||
| fourth push, then pops it empty: 1.24x in Node, 1.11x in Chrome, 2.3x in Bun, and 2.8x | ||
| in Firefox, every other workload within noise. The maintainer kept the guarantee-only | ||
| model on 2026-11-02, accepting that a deque made from a shrunk `Vec` may split | ||
| differently from std's. | ||
| - Untried: a `Vec` as a wrapper object holding its own length and capacity over its | ||
| array, measured on the same workload before it is weighed against that decision. | ||
|
|
||
| Public API: the translator's output. |
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
rg -n 'function capOf|function dequeFromVec|function dequeAsSlices|as_slices|shrunk.*Vec' ts/runtime/rt/collections.ts ts/fixtures/lang/src/rings.rs quest/m3/ts-vec-exact-capacity.mdRepository: moq-dev/rust2
Length of output: 1306
Script executed:
Repository: moq-dev/rust2
Length of output: 9292
Script executed:
Repository: moq-dev/rust2
Length of output: 1141
Script executed:
Repository: moq-dev/rust2
Length of output: 4221
Script executed:
Repository: moq-dev/rust2
Length of output: 4158
Script executed:
Repository: moq-dev/rust2
Length of output: 3707
Document the shrunk-
Vecsplit exception in theVecDequedescription.The
as_slicessentence says every deque splits as std's. A deque made from aVecthatpop,truncate, ordrainshrank can split differently. That case is not stated ints/README.mdorts/MIGRATE.md. Name the exception in the same sentence.📝 Suggested wording
Committable suggestion