Repository navigation
feat(ts): translate vec![x; n] of a value that drops - #534
Merged
Merged
Conversation
Quest-Claim: 0742fbd660b17f12
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 3, 2026 18:45
|
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 3 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
vec![x; n]was refused whenxdrops ("passingT, which drops, tovec::from_elem"), since nothing droppedxforn == 0.Approach
vec::from_elemjoinsdiscardswith its element, so the mapping handsrt.vecFromElemthe element's dropper.rt.vecFromElemdrops the value wherenis 0. Otherwise it keeps std's order:n - 1clones in order, then the original moved into the last slot.clones::repeats, checked against native Rust, logs every clone and drop of: aLogged; a type with its ownClone; an enum; an array; anOption; a tuple holding aString; aVec(with capacities, so the original row is told apart from its exact-capacity clones); nestedvec![vec![x; m]; n]; and a genericT: Clone.ncomes from the input (0 to 4), plus a literal 0. One case logs while it evaluates the count, which showsxis made first.n == 0drop removed.Consumer: std coverage planned in m3 (found writing
clones::clone_froms); moq does not call it yet.Impact
vec![x; n]of a droppingTnow translates. Othervec![x; n]output is unchanged.vecFromElemtakes an optional trailingdrop.Alternatives
vecResizeon an empty vector, as the quest suggested. It reserves throughsizeand always dropsvaluewhen shrinking, so it saves nothing over the 4-line change here.Follow-ups
None.
Review
Codex gpt-6.1-sol, medium effort, via
quest review, round 2 on head b8201c9: no findings.ts/src/lower/collections.rs:574(custom BuildHasher state). Refuted: this branch doesn't touch that file. The round diffed against a newer origin/main that held feat(ts): hold a crate's own BuildHasher in a hash map or set #509, so feat(ts): hold a crate's own BuildHasher in a hash map or set #509 looked like a revert here. Merging origin/main removed it from the diff.🤖 Generated with Claude Code