diff --git a/crates/typos/src/parser.rs b/crates/typos/src/parser.rs index f62bffb..883a730 100644 --- a/crates/typos/src/parser.rs +++ b/crates/typos/src/parser.rs @@ -26,14 +26,14 @@ impl<'p, 'd> ParserBuilder<'p, 'd> { pub fn dictionary<'d1>(self, dictionary: &'d1 dyn Dictionary) -> ParserBuilder<'p, 'd1> { ParserBuilder { tokenizer: self.tokenizer, - dictionary: dictionary, + dictionary, } } /// Extract typos from the buffer. pub fn build(&self) -> TyposParser<'p, 'd> { TyposParser { - tokenizer: self.tokenizer.unwrap_or_else(|| &DEFAULT_TOKENIZER), + tokenizer: self.tokenizer.unwrap_or(&DEFAULT_TOKENIZER), dictionary: self.dictionary, } } @@ -49,7 +49,7 @@ impl<'p> Default for ParserBuilder<'p, 'static> { } static DEFAULT_TOKENIZER: once_cell::sync::Lazy = - once_cell::sync::Lazy::new(|| tokens::Tokenizer::new()); + once_cell::sync::Lazy::new(tokens::Tokenizer::new); /// Extract typos from the buffer. #[derive(Clone)] diff --git a/src/checks.rs b/src/checks.rs index 36d8980..3bfb25b 100644 --- a/src/checks.rs +++ b/src/checks.rs @@ -331,12 +331,7 @@ impl FileChecker for DiffTypos { if new_path.is_some() || !content.is_empty() { let original_path = path.display().to_string(); - let fixed_path = new_path - .as_ref() - .map(|p| p.as_path()) - .unwrap_or(path) - .display() - .to_string(); + let fixed_path = new_path.as_deref().unwrap_or(path).display().to_string(); let original_content: Vec<_> = content .lines_with_terminator() .map(|s| String::from_utf8_lossy(s).into_owned()) @@ -595,7 +590,7 @@ fn extract_fix<'t>(typo: &'t typos::Typo<'t>) -> Option<&'t str> { } } -fn is_fixable<'t>(typo: &typos::Typo<'t>) -> bool { +fn is_fixable(typo: &typos::Typo<'_>) -> bool { extract_fix(typo).is_some() } diff --git a/src/report.rs b/src/report.rs index 3d213cd..08b2f28 100644 --- a/src/report.rs +++ b/src/report.rs @@ -234,10 +234,21 @@ impl<'r> MessageStatus<'r> { impl<'r> Report for MessageStatus<'r> { fn report(&self, msg: Message) -> Result<(), std::io::Error> { - self.typos_found - .compare_and_swap(false, msg.is_correction(), atomic::Ordering::Relaxed); - self.errors_found - .compare_and_swap(false, msg.is_error(), atomic::Ordering::Relaxed); + let _ = self.typos_found.compare_exchange( + false, + msg.is_correction(), + atomic::Ordering::Relaxed, + atomic::Ordering::Relaxed, + ); + let _ = self + .errors_found + .compare_exchange( + false, + msg.is_error(), + atomic::Ordering::Relaxed, + atomic::Ordering::Relaxed, + ) + .unwrap(); self.reporter.report(msg) } }