Repository navigation
feat(ts): translate String + &str and Cow<str>'s + as += does - #479
Merged
Merged
Conversation
Quest-Claim: e3a4eec625b7d82b
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 3, 2026 04:13
|
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 15 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
|
# Conflicts: # ts/fixtures/lang/cows/expected/cows.ts
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
rust2-ts refused
String + &str("unsupported call to<String as Add<&str>>::add") while+=mapped.Cow<str>'s+and+=(of a&stror anotherCow<str>) were refused too, though aCow<str>is the same JS string.Approach
library.rs:Add::addwhoseSelfis a JS string (StringorCow<str>) is JS+of the moved text. Library mappings only see std's impls, so a crate's ownAddonStringstill calls the crate's.call.rs: thepush/push_str/add_assignarm now takes any stdAddAssignon a JS string (Cow<str>included), and skips a crate's ownimpl AddAssign<Local> for String, which it used to swallow.lang/strsandlang/cowsfixtures):strs::edit:+=,mem::take(s) + &piece, a chain with""and&&str, andString::with_capacity(a) + sthrough deref of the&mut String, over empty and multi-width text. The moved-from string's capacity reuse is unobservable, ascapacityis refused.strs::edits:+of the moved local itself.cows:+and+=of&strandCow, including an empty left side, where std borrows the right side.ts/README.mdnotes+.Impact
String + &str,Cow<str> + &str,Cow<str> + Cow<str>, andCow<str> += &str | Cow<str>translate instead of being refused. No public Rust API change.Alternatives
Stringonly, per the quest's letter. Dropped:Cow<str>'s+is the same gap with the same representation, so leaving it would split one problem across PRs.Follow-ups
ts-operator-paths.md(quest: plan operator trait methods called by path #481) to the quest this PR deletes.s.pop()on a local that another arm assigns whole (s = String::from("x"), no+involved) writes through an undeclaredrt.Place, sotscfails. Pre-existing and independent of this change; the test shadows the local instead of reassigning it.Checks
just cipassed on 0f46b6c, merged with main at 3d37327.+operands fails the native differential oflang::strs(1746 differences) andlang::cows(13).Review
quest review), round 2.🤖 Generated with Claude Code