rust-lang / rust-lang/rust-clippy
uninlined_format_args is too strict around renamed args
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
clippy suggests inlining a format arg that has been explicitly renamed
Lint Name
uninlined_format_args
Reproducer
I tried this code:
fn main() {
let val = "World";
println!("Hello, {name}!", name = val);
}
I saw this happen:
warning: variables can be used directly in the `format!` string
--> src/main.rs:3:5
|
3 | println!("Hello, {name}!", name = val);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
= note: `#[warn(clippy::uninlined_format_args)]` on by default
help: change this to
|
3 - println!("Hello, {name}!", name = val);
3 + println!("Hello, {val}!");
|
I expected to see this happen:
No warning
Version
rustc 1.67.0 (fc594f156 2023-01-24)
binary: rustc
commit-hash: fc594f15669680fa70d255faec3ca3fb507c3405
commit-date: 2023-01-24
host: aarch64-apple-darwin
release: 1.67.0
LLVM version: 15.0.6
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 with the uninlined_format_args lint and reproduce the warning using the Rust snippet in the issue. Trace how the lint handles explicitly renamed arguments, then add a regression case so this form produces no warning and verify the existing diagnostic behavior remains covered.
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
- 45/100