Skip to content

feat(ts): accept an empty iterator of mutable references as a place source - #497

Merged
kixelated merged 5 commits into
mainfrom
quest/m3/ts-empty-places
Nov 3, 2026
Merged

kixelated merged 5 commits into
mainfrom
quest/m3/ts-empty-places

Conversation

@kixelated

@kixelated kixelated commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

std::iter::empty::<&mut T>() for a T JS copies, as given to zip or chain, was refused as "a mutable reference to a value JS copies, which its mapping would copy", though it yields nothing to write through. Default::default() of an empty iterator of places (iter::Empty, a LinkedList's IterMut or IntoIter) was refused by the same check, as #362 noted when it left IterMut::<u8>::default() in the reject fixture.

Approach

  • std_places treats iter::empty and Default::default of an iterator whose default yields nothing as lending places, like a &mut collection given to into_iter.
  • library::empty_default names those iterators, sharing a new list_iter matcher with default_value's list arm.
  • refs::adapted in the lang fixture chains and zips iter::empty on either side of a &mut Vec and Option of bytes, and chains Empty::default() and a list's IterMut and IntoIter defaults, differentially against native Rust. The reject fixture drops IterMut::<u8>::default(), which now translates.

Impact

  • Translator output only: these calls now translate instead of being refused. No API change.

Alternatives

  • Accepting any call that yields places but takes none: too broad, since iter::from_fn and similar make places in closures the check exists for.

Follow-ups

None.

Review

Codex, gpt-6.1-sol, medium effort, round 1 on 18ab8cb: no findings. Since then, only conflict-free merges of origin/main (#492, #494, #463).

🤖 Generated with Claude Code

@kixelated kixelated changed the title An empty iterator of mutable references feat(ts): accept an empty iterator of mutable references as a place source Nov 3, 2026
@kixelated
kixelated marked this pull request as ready for review November 3, 2026 06:52
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

The lowering code now recognizes empty iterators and default-empty linked-list iterators as lending no places. It also represents default linked-list iterators as iterators over an empty list. Language fixtures add chain and zip cases with empty iterators. Rejection fixtures remove the Default::default case for a mutable reference to a copied value. The deferred-task entry and its plan document are removed.

Merge Risk: Minimal · up to 4caa4

No actionable merge-blocking issue is identified in the empty-iterator handling changes. Merge after normal checks pass.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: accepting empty iterators of mutable references as place sources.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description directly explains the empty-iterator handling changes, the affected fixtures, the implementation approach, and the translator-only impact. It matches the changeset.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 5 files.

Finishing Touches
Simplify code
  • Commit to this branch
  • Create a new PR
  • 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.
Recent review info
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: 510f1630-f49b-4510-90fd-075ff21ee210
Commits

Reviewing files that changed from the base of the PR and between ab8f549 and 4caa41f.

Files selected for processing: 9
  • quest/m3/README.md
  • quest/m3/ts-empty-places.md
  • ts/fixtures/lang/refs/expected/refs.ts
  • ts/fixtures/lang/refs/src/refs.rs
  • ts/fixtures/reject/census.txt
  • ts/fixtures/reject/expected.txt
  • ts/fixtures/reject/src/values.rs
  • ts/src/lower/library.rs
  • ts/src/lower/mir/call.rs
Files with no reviewable changes: 1
  • quest/m3/ts-empty-places.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@kixelated
kixelated enabled auto-merge November 3, 2026 06:55
@kixelated
kixelated added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 8c7a301 Nov 3, 2026
5 checks passed
@kixelated
kixelated deleted the quest/m3/ts-empty-places branch November 3, 2026 07:04
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