rust-lang / rust-lang/rust-clippy
Warn about unused named parameter in format strings
Open
@miam-miam is already working on this.
Since Jun 20, 2022.
A-lint
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
Very few beginners know that named parameters can be used in format strings. (https://doc.rust-lang.org/std/fmt/index.html#named-parameters) This can often lead to great confusion as it looks like you are setting the variable to that value.
Additionally since you can now capture identifiers in format strings, named parameters will become less and less common. As such this new lint warns if a named parameter goes unused.
Lint Name
unused_named_parameter
Category
suspicious
Advantage
- Removes redundant code
- Prevents named parameters from being confused with an assignment such as
print!("{}", x = x+1)
Drawbacks
No response
Example
println!("{}", x = 10);
Could be written as:
println!("{}", 10);
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.
Assessment
This issue has not been assessed yet.