RS.CLIPPY.TO_STRING_IN_FORMAT_ARGS
`to_string` applied to a type that implements `Display` in format args
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: to_string_in_format_args. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for ToString::to_string
applied to a type that implements Display
in a macro that does formatting.
Why is this bad?
Since the type implements Display, the use of to_string is
unnecessary.
Example
println!("error: something failed at {}", Location::caller().to_string());
Use instead:
println!("error: something failed at {}", Location::caller());