Closed
Description
What it does
assert!
and panic!
have built-in support for formatting, but they also accept arguments of type String
, so one could use format!
instead.
Using format!
here is entirely unnecessary, and yet happens in the wild, so this seems like a useful target for a Clippy lint. Also the long-term plan is to not support String
arguments any more, so such code might not work in future editions.
Cc @m-ou-se
Example
panic!(format!("hello {}", var))
assert!(x, format!("hello {}", var))
Could be written as:
panic!("hello {}", var)
assert!(x, "hello {}", var)