RS.CLIPPY.FORMAT_IN_FORMAT_ARGS
`format!` used in a macro that does formatting
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: format_in_format_args. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Detects format! within the arguments of another macro that does
formatting such as format! itself, write! or println!. Suggests
inlining the format! call.
Why is this bad?
The recommended code is both shorter and avoids a temporary allocation.
Example
println!("error: {}", format!("something failed at {}", Location::caller()));
Use instead:
println!("error: something failed at {}", Location::caller());