Skip to content

feat(ts): translate vec![x; n] of a value that drops - #534

Merged
kixelated merged 4 commits into
mainfrom
quest/m3/ts-vec-from-elem-drops
Nov 3, 2026
Merged

kixelated merged 4 commits into
mainfrom
quest/m3/ts-vec-from-elem-drops

Conversation

@kixelated

@kixelated kixelated commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

vec![x; n] was refused when x drops ("passing T, which drops, to vec::from_elem"), since nothing dropped x for n == 0.

Approach

  • vec::from_elem joins discards with its element, so the mapping hands rt.vecFromElem the element's dropper.
  • rt.vecFromElem drops the value where n is 0. Otherwise it keeps std's order: n - 1 clones in order, then the original moved into the last slot.
  • New differential case clones::repeats, checked against native Rust, logs every clone and drop of: a Logged; a type with its own Clone; an enum; an array; an Option; a tuple holding a String; a Vec (with capacities, so the original row is told apart from its exact-capacity clones); nested vec![vec![x; m]; n]; and a generic T: Clone. n comes from the input (0 to 4), plus a literal 0. One case logs while it evaluates the count, which shows x is made first.
  • Verified the case fails with the n == 0 drop removed.

Consumer: std coverage planned in m3 (found writing clones::clone_froms); moq does not call it yet.

Impact

  • Translator output: vec![x; n] of a dropping T now translates. Other vec![x; n] output is unchanged.
  • Runtime: vecFromElem takes an optional trailing drop.

Alternatives

  • Reusing vecResize on an empty vector, as the quest suggested. It reserves through size and always drops value when 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.

🤖 Generated with Claude Code

kixelated and others added 2 commits November 3, 2026 07:12
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Repeated values that drop feat(ts): translate vec![x; n] of a value that drops Nov 3, 2026
@kixelated
kixelated marked this pull request as ready for review November 3, 2026 18:45
@pullfrog

pullfrog Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

This run was cancelled before it finished.

Pullfrog  | View workflow run | via Pullfrog

@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7ca9ae02-e9c6-4d6b-8aa2-db076bab7bf1
Commits

Reviewing files that changed from the base of the PR and between 8846329 and b8201c9.

Files selected for processing: 9
  • quest/m3/README.md
  • quest/m3/ts-vec-from-elem-drops.md
  • ts/fixtures/lang/clones/expected/clones.ts
  • ts/fixtures/lang/clones/expected/core/option.ts
  • ts/fixtures/lang/clones/expected/lib.ts
  • ts/fixtures/lang/clones/src/clones.rs
  • ts/fixtures/lang/clones/src/lib.rs
  • ts/runtime/rt.ts
  • ts/src/lower/library.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@kixelated
kixelated enabled auto-merge November 3, 2026 18:45
@kixelated
kixelated added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 090291b Nov 3, 2026
7 of 8 checks passed
@kixelated
kixelated deleted the quest/m3/ts-vec-from-elem-drops branch November 3, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant