rust-lang / rust-lang/rust-clippy
Overzealous `uninlined_format_args`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Description
Consider this snippet from a match statement:
Self::TemplateSwitchExit {
entrance_reference_index,
entrance_query_index,
template_switch_primary,
template_switch_secondary,
primary_index,
anti_primary_gap,
} => write!(
f,
"TemplateSwitchExit({}R, {}Q, {}P, {}G, {}, {})",
entrance_reference_index,
entrance_query_index,
primary_index,
anti_primary_gap,
template_switch_primary,
template_switch_secondary
),
Clippy wants me to put all format args into the string, but that would make the string incredibly long. cargo fmt would not break up the string into multiple lines either.
I think the code is easier to read like this. Clippy should not suggest inlining format args if the resulting string gets too long.
Version
rustc 1.88.0-nightly (df35ff6c3 2025-04-23)
binary: rustc
commit-hash: df35ff6c354f1f1fbf430b84e7dea37dfe997f34
commit-date: 2025-04-23
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2
Additional Labels
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the uninlined_format_args lint and reproduce the report with the provided match statement and write! call. The work is done when the lint avoids suggesting inlining that would make the format string excessively long, with regression coverage for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100