Skip to content

Write string joins as format! in Rust and note them in C - #323

Open
matt-edmondson wants to merge 2 commits into
mainfrom
claude/project-thread-kddtpg-240
Open

matt-edmondson wants to merge 2 commits into
mainfrom
claude/project-thread-kddtpg-240

Conversation

@matt-edmondson

@matt-edmondson matt-edmondson commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Before: a string join such as "Hello, " + name came out as + in Rust and C. Neither compiler accepts it. Rust implements + only as String + &str, so a literal on the left or a String on the right is rejected (E0369/E0308). C has no operator that joins strings at all.

After: in Rust a join of strings is written as a single format! call, which compiles whichever side holds the literal. In C the + is kept, with a note beside it that says why it cannot compile and what to write instead.

How: Rust function bodies now open a static type scope, so the generator knows the types of the parameters and locals and can tell a string join from adding numbers. StringConcatenationTests covers both targets.

Closes #240

https://claude.ai/code/session_018tZnrna9oooMZHDaLyXumk


Generated by Claude Code

Rust implements + only as String + &str, so a literal on the left or a
String on the right did not compile; a join of strings is now one
format! call. Rust function bodies now open a static type scope so the
parameters' and locals' types are known. C has no expression for a
join, so the + keeps a note saying why and what to write instead.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018tZnrna9oooMZHDaLyXumk
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018tZnrna9oooMZHDaLyXumk
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

String concatenation (Add on string operands) fails to compile in C and Rust: "Hello, " + name (C: invalid operands; Rust: E0369/E0308)

2 participants