Skip to content

Fix uninlined_format_args clippy lint#1289

Open
PeterXMR wants to merge 1 commit into
romanz:masterfrom
PeterXMR:fix-uninlined-format-args
Open

Fix uninlined_format_args clippy lint#1289
PeterXMR wants to merge 1 commit into
romanz:masterfrom
PeterXMR:fix-uninlined-format-args

Conversation

@PeterXMR
Copy link
Copy Markdown

Closes #1199.

Inlines format-string arguments throughout the crate so cargo clippy -W clippy::uninlined_format_args passes, and removes the crate-wide [lints.clippy] uninlined_format_args = \"allow\" block in Cargo.toml.

How it was produced

The bulk was generated mechanically:

cargo clippy --fix --allow-dirty --all-targets -- -W clippy::uninlined_format_args

This rewrites every format!(\"... {}\", x) (and its eprintln! / info! / write! cousins) into the inlined format!(\"... {x}\") form. clippy's autofix is conservative — it skips a handful of sites with method-call arguments or shadowed identifiers — but in this codebase it covered every site in 14 files. Two additional single-line sites in src/index.rs and src/signals.rs that the fix log did not announce but the autofix did rewrite are included.

Followed by a cargo fmt --all pass to normalise the line wrapping that the rewrite occasionally collapsed.

Behaviour change

None. The inlined format!(\"... {x}\") form produces byte-identical output to the previous format!(\"... {}\", x). This is a purely syntactic refactor.

Tests

No new tests are needed for a syntactic refactor — the existing test suite is the regression check, since several tests assert on formatted output:

Test Asserts on …
config::tests::test_auth_debug SensitiveAuth's Debug output (goes through inlined write!)
electrum::tests::test_requests / test_version request/response JSON whose error paths use inlined format!
status::tests::test_txinfo_json transaction-info JSON formatting
types::tests::test_scripthash_serde scripthash hex formatting

All 21 lib tests pass on every CI matrix configuration:

  • cargo test --locked --no-default-features --all
  • cargo test --locked --all
  • cargo test --locked --features metrics_process --all(on Linux — prometheus::process_collector is target_os = \"linux\"-gated, so this config can't build on macOS regardless of the refactor; CI runs on ubuntu-latest)

Plus a focused integration smoke test against Bitcoin Core 31 on regtest, exercising every RPC code path through the Electrum protocol (relayfee, estimatefee, transaction.get hex+verbose, mempool fee_histogram, broadcast of a fresh signed tx) — all clean.

Notes for review

  • Generated configure_me_config.rs in OUT_DIR has its own uninlined_format_args hits from configure_me_codegen's output. They don't trigger CI's cargo clippy -- -D warnings because the lint is allow-by-default at clippy's level (it's a pedantic-group lint). If you'd like to enforce going forward — i.e., promote the lint to warn in [lints.clippy] and rely on -D warnings to deny it — I'd need to also add #![allow(clippy::uninlined_format_args)] to the mod internal { ... } block in src/config.rs so the generated code stays quiet. Happy to do that as a follow-up, or to bundle it here if you prefer; I left it out because the issue's literal scope is just "fix the lint" rather than "enforce going forward".
  • This PR is independent of Drop archived bitcoincore-rpc dependency #1288 (drop bitcoincore-rpc) — the diffs don't overlap on any line. They will rebase against each other cleanly in either order.

Inline format-string arguments throughout the crate so the lint passes
with `cargo clippy -W clippy::uninlined_format_args`, and drop the
crate-wide `allow` from `Cargo.toml`.

The bulk of the rewrite was produced mechanically via
`cargo clippy --fix --all-targets -- -W clippy::uninlined_format_args`;
two single-line sites in `src/index.rs` and `src/signals.rs` that
clippy's autofix did not announce but did rewrite are included. All
changes are stylistic — the inlined `format!("... {x}")` form produces
byte-identical output to the previous `format!("... {}", x)` form.

The existing test suite is the regression check (no new tests are
needed for a syntactic refactor):
- `config::tests::test_auth_debug` asserts on `SensitiveAuth`'s Debug
  output, which goes through inlined `write!`.
- `electrum::tests::*` exercise request/response shapes whose error
  paths use inlined `format!`.
- `status::tests::test_txinfo_json` exercises tx-info JSON formatting.

All 21 lib tests pass on every CI matrix configuration
(`--locked --no-default-features`, `--locked`,
`--locked --features metrics_process`). Integration smoke against
Bitcoin Core 31 on regtest also clean.

Closes romanz#1199

Co-Authored-By: Claude Opus 4.7 (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.

Fix uninlined_format_args clippy lint

1 participant