From 5062c092de9d632423c780643c4197f1bdb12f66 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sun, 18 Aug 2024 07:24:32 +0800 Subject: [PATCH] fix: BinaryFile display --- crates/typos-cli/src/bin/typos-cli/report.rs | 4 ++-- crates/typos-cli/src/file.rs | 4 ++-- crates/typos-cli/src/policy.rs | 2 +- crates/typos-cli/src/report.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/typos-cli/src/bin/typos-cli/report.rs b/crates/typos-cli/src/bin/typos-cli/report.rs index a70bd91f6..c45b24ec2 100644 --- a/crates/typos-cli/src/bin/typos-cli/report.rs +++ b/crates/typos-cli/src/bin/typos-cli/report.rs @@ -63,7 +63,7 @@ impl Report for PrintBrief { fn report(&self, msg: Message<'_>) -> Result<(), std::io::Error> { match &msg { Message::BinaryFile(msg) => { - log::info!("{}", msg); + log::info!("{msg}"); } Message::Typo(msg) => print_brief_correction(msg)?, Message::FileType(msg) => { @@ -97,7 +97,7 @@ impl Report for PrintLong { fn report(&self, msg: Message<'_>) -> Result<(), std::io::Error> { match &msg { Message::BinaryFile(msg) => { - log::info!("{}", msg); + log::info!("{msg}"); } Message::Typo(msg) => print_long_correction(msg)?, Message::FileType(msg) => { diff --git a/crates/typos-cli/src/file.rs b/crates/typos-cli/src/file.rs index a49b4107b..c7f377c71 100644 --- a/crates/typos-cli/src/file.rs +++ b/crates/typos-cli/src/file.rs @@ -474,7 +474,7 @@ fn read_file( let (r, written) = encoding_rs::UTF_16LE.new_decoder_with_bom_removal().decode_to_string_without_replacement(&buffer, &mut decoded, true); let decoded = match r { encoding_rs::DecoderResult::InputEmpty => Ok(decoded), - _ => Err(format!("invalid UTF-16LE encoding at byte {} in {}", written, path.display())), + _ => Err(format!("invalid UTF-16LE encoding at byte {written} in {}", path.display())), }; let buffer = report_result(decoded, Some(path), reporter)?; (buffer.into_bytes(), content_type) @@ -487,7 +487,7 @@ fn read_file( let (r, written) = encoding_rs::UTF_16BE.new_decoder_with_bom_removal().decode_to_string_without_replacement(&buffer, &mut decoded, true); let decoded = match r { encoding_rs::DecoderResult::InputEmpty => Ok(decoded), - _ => Err(format!("invalid UTF-16BE encoding at byte {} in {}", written, path.display())), + _ => Err(format!("invalid UTF-16BE encoding at byte {written} in {}", path.display())), }; let buffer = report_result(decoded, Some(path), reporter)?; (buffer.into_bytes(), content_type) diff --git a/crates/typos-cli/src/policy.rs b/crates/typos-cli/src/policy.rs index daf4cc85d..36ea21efc 100644 --- a/crates/typos-cli/src/policy.rs +++ b/crates/typos-cli/src/policy.rs @@ -319,7 +319,7 @@ impl DirConfig { let config = name .and_then(|name| { - log::debug!("{}: `{}` policy", path.display(), name); + log::debug!("{}: `{name}` policy", path.display()); self.types.get(name).copied() }) .unwrap_or_else(|| { diff --git a/crates/typos-cli/src/report.rs b/crates/typos-cli/src/report.rs index 8ebf12e33..96d67a4d1 100644 --- a/crates/typos-cli/src/report.rs +++ b/crates/typos-cli/src/report.rs @@ -62,7 +62,7 @@ impl<'m> Message<'m> { } #[derive(Clone, Debug, serde::Serialize, derive_more::Display, derive_setters::Setters)] -#[display("Skipping binary file {}", "path.display()")] +#[display("Skipping binary file {}", path.display())] #[non_exhaustive] pub struct BinaryFile<'m> { pub path: &'m std::path::Path,