Skip to content

chore(lint): enable clippy::string_add - #240

Open
tupe12334 wants to merge 1 commit into
mainfrom
clippy/enable-string-add
Open

tupe12334 wants to merge 1 commit into
mainfrom
clippy/enable-string-add

Conversation

@tupe12334

Copy link
Copy Markdown
Member

Closes #239

What

Promote one more Clippy lint in the incremental ratchet: clippy::string_add = "deny" in the [lints.clippy] table of core/Cargo.toml.

clippy::string_add flags string concatenation through the + operator (a + &b, a + "\n") and asks for String::push_str() / String::push() instead. That makes the mutation and the ownership move explicit, and it reuses the existing buffer rather than reallocating per concatenation.

The lint pairs with clippy::format_push_string, clippy::manual_string_new and clippy::str_to_string, which the crate already denies, so all string building now follows one idiom.

Changes

  • core/Cargo.toml: add string_add = "deny".
  • core/src/scripts.rs: the one violation the lint surfaced. lines.join("\n") + "\n" becomes a named String with a push('\n'). Same output, no behaviour change.

Verification

Run in core/:

  • cargo fmt --check — clean
  • cargo clippy --all-targets --all-features — no issues
  • cargo test — 191 passed

This pull request was opened automatically by the moadim routine "Clippy lint improvements → issue + PR (Rust repos) → Slack".

Add `string_add = "deny"` to the `[lints.clippy]` table and rewrite the
single violation in `scripts.rs` to build the script with `push` instead
of `String + &str`.

Opened by the moadim routine "Clippy lint improvements -> issue + PR
(Rust repos) -> Slack".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

Enable clippy::string_add lint

1 participant