Closed
Description
Summary
If a format string starts with a \n
, the lint does not seem to fire.
I had a quick glance at the lint code but I didn't see anything that would indicate that this is intentional.
Lint Name
clippy::write_with_newline
Reproducer
I tried this code:
use std::fmt::Write as _;
pub fn main() {
let mut s = String::new();
let x = "a";
write!(s, "\n{}\n", x).unwrap(); // should warn
dbg!(s);
}
would expect a warning here since we can write writeln!(s, "\n{}")
Version
clippy 0.1.62 (7b8a08cf1 2022-04-21)