Gracefully handle lint panics (#3509)

This commit is contained in:
Micha Reiser 2023-03-19 17:08:38 +01:00 committed by GitHub
parent f06dff8af8
commit 9ac9a1c69e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 93 additions and 10 deletions

View file

@ -1,6 +1,6 @@
use std::fmt::Write;
use std::io;
use std::io::BufWriter;
use std::io::Write;
use anyhow::Result;
use itertools::Itertools;
@ -41,7 +41,7 @@ pub fn linter(format: HelpFormat) -> Result<()> {
.join("/"),
prefix => prefix.to_string(),
};
output.push_str(&format!("{:>4} {}\n", prefix, linter.name()));
writeln!(output, "{:>4} {}", prefix, linter.name()).unwrap();
}
}
@ -65,7 +65,7 @@ pub fn linter(format: HelpFormat) -> Result<()> {
}
}
write!(stdout, "{output}")?;
io::Write::write_fmt(&mut stdout, format_args!("{output}"))?;
Ok(())
}