Fix uninlined_format_args clippy lint#1289
Open
PeterXMR wants to merge 1 commit into
Open
Conversation
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>
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.
Closes #1199.
Inlines format-string arguments throughout the crate so
cargo clippy -W clippy::uninlined_format_argspasses, and removes the crate-wide[lints.clippy] uninlined_format_args = \"allow\"block inCargo.toml.How it was produced
The bulk was generated mechanically:
This rewrites every
format!(\"... {}\", x)(and itseprintln!/info!/write!cousins) into the inlinedformat!(\"... {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 insrc/index.rsandsrc/signals.rsthat the fix log did not announce but the autofix did rewrite are included.Followed by a
cargo fmt --allpass to normalise the line wrapping that the rewrite occasionally collapsed.Behaviour change
None. The inlined
format!(\"... {x}\")form produces byte-identical output to the previousformat!(\"... {}\", 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:
config::tests::test_auth_debugSensitiveAuth's Debug output (goes through inlinedwrite!)electrum::tests::test_requests/test_versionformat!status::tests::test_txinfo_jsontypes::tests::test_scripthash_serdeAll 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_collectoristarget_os = \"linux\"-gated, so this config can't build on macOS regardless of the refactor; CI runs onubuntu-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
configure_me_config.rsinOUT_DIRhas its ownuninlined_format_argshits fromconfigure_me_codegen's output. They don't trigger CI'scargo clippy -- -D warningsbecause the lint isallow-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 towarnin[lints.clippy]and rely on-D warningsto deny it — I'd need to also add#![allow(clippy::uninlined_format_args)]to themod internal { ... }block insrc/config.rsso 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".bitcoincore-rpcdependency #1288 (dropbitcoincore-rpc) — the diffs don't overlap on any line. They will rebase against each other cleanly in either order.