Skip to content

chore(quest): plan matching a Cow<str>'s variant - #541

Merged
kixelated merged 1 commit into
mainfrom
quest-plan/ts-cow-str-variant
Nov 3, 2026
Merged

kixelated merged 1 commit into
mainfrom
quest-plan/ts-cow-str-variant

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Problem

A Cow<str> is a plain JS string (#105), so matching its Borrowed or Owned variant is refused, and to_mut never changes the variant. Found in #537, where the variant of from_utf8_lossy's result can't be tested. The maintainer chose to plan it on 2026-11-03.

Approach

Adds quest/m3/ts-cow-str-variant.md [L], linked from quest/m3/README.md:

  • Goal: matching the variant, plus into_owned and to_mut, translate as std's do, proven by differential tests that include from_utf8_lossy's variant. is_borrowed/is_owned are unstable (cow_is_borrowed) and stay refused.
  • Plan: names where translation refuses today. Lays out the representation options: a wrapper only where some match observes the variant, found whole-program, or a wrapper everywhere. Each is to be measured against the plain string on the TS bench and moq's codec before choosing.

Impact

  • Public API: none (quest only).

Alternatives

  • Leaving Cow<str> without variants for good: it conflicts with the plan to cover all of std.

Follow-ups

None.

Review

Skipped: a quest-only plan with no code. just check passed on 922e4c451553f9422f127f01dc3e689de9dadd63.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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 50 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: a779d6f0-9b35-4ccf-819f-cf4378514cb1
Commits

Reviewing files that changed from the base of the PR and between 090291b and 922e4c4.

Files selected for processing: 2
  • quest/m3/README.md
  • quest/m3/ts-cow-str-variant.md
  • 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 added this pull request to the merge queue Nov 3, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one minor suggestion inline.

Reviewed changes

  • New quest doc quest/m3/ts-cow-str-variant.md — plans matching a Cow<str>'s Borrowed/Owned and into_owned/to_mut's variant semantics, noting what refuses today and laying out three representation options to measure on the TS bench and moq's codec.
  • Index row in quest/m3/README.md — links the new quest from m3's list.

Quest-only plan, no code. I verified the plan's claims against the source: the library::cow_variant refusal sites match (ts/src/lower/mir/place.rs:644, ts/src/lower/mir/place.rs:1245, ts/src/lower/mir/rvalue.rs:562, ts/src/lower/library.rs:2590); into_owned indeed returns the text unchanged and to_mut is same_place while nothing reads the variant; Cow<[T]> splits on rt.Borrowed/rt.ByteSlice as the shape hint says; and the lang/cows, lang/utf8, and reject fixtures all exist as named. Format matches neighboring m3 quest docs.

(Written by glm-5.3-flash)

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using glm-5.3-flash | 𝕏


`Cow<[T]>` already keeps its variant (`rt.Borrowed`, or a `ByteSlice` against a
`ByteVec`), which may suggest a shape. The tests belong in the `lang/cows` and `lang/utf8`
fixtures. The `reject` fixture's `Cow<str>` cases move to them.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not every Cow<str> case in reject/src/strs.rs can move: cow_borrowed asks is_borrowed on a Cow<str>, which this quest keeps refused. Worth scoping this to the cases the quest resolves (the match), leaving cow_borrowed in place.

Technical details
# reject fixture's Cow<str> cases can't all move

## Affected sites
- quest/m3/ts-cow-str-variant.md:42 — "The `reject` fixture's `Cow<str>` cases move to them" sweeps in `cow_borrowed`, which stays refused.

## Required outcome
- The plan should say only the variant-matching case (`cow_matched`) moves to `lang/cows`; `cow_borrowed` (`is_borrowed` on a `Cow<str>`) stays in `reject` because `is_borrowed` remains refused per the Goal.

## Suggested approach
- "The `reject` fixture's matching case moves there" or naming `cow_matched` directly.

Merged via the queue into main with commit f0b2a31 Nov 3, 2026
5 checks passed
@kixelated
kixelated deleted the quest-plan/ts-cow-str-variant branch November 3, 2026 19:07
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