Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

fix(core): appease clippy

Elijah Potterd70d92723849
diff --git a/harper-core/src/linting/it_would_be.rs b/harper-core/src/linting/it_would_be.rs
index ddaa2b47b..098f83ae5 100644
--- a/harper-core/src/linting/it_would_be.rs
+++ b/harper-core/src/linting/it_would_be.rs
@@ -1,10 +1,9 @@
use crate::{
Token,
linting::{Lint, LintKind, PatternLinter, Suggestion},
- patterns::{EitherPattern, OwnedPatternExt, Pattern, SequencePattern, WordSet},
+ patterns::{OwnedPatternExt, Pattern, SequencePattern, WordSet},
};
-/// Corrects “I might not be a shame …” → “it might not be a shame …”
pub struct ItWouldBe {
pattern: Box<dyn Pattern>,
}
@@ -29,8 +28,6 @@ impl Default for ItWouldBe {
"challenge",
]);
- /* ─────────────── pattern builder ─────────────── */
- // helper fn to build the four concrete branches (±not, ±adj)
let branch = |has_not: bool, has_adj: bool| {
let mut p = SequencePattern::default()
.then(head_verbs.clone())
@@ -52,7 +49,6 @@ impl Default for ItWouldBe {
p.then_whitespace().then(tail_nouns.clone())
};
- // Assemble the 4 branches with EitherPattern
let combined = branch(false, false)
.or(Box::new(branch(false, true)))
.or(Box::new(branch(true, false)))
@@ -69,7 +65,7 @@ impl PatternLinter for ItWouldBe {
self.pattern.as_ref()
}
- fn match_to_lint(&self, toks: &[Token], src: &[char]) -> Option<Lint> {
+ fn match_to_lint(&self, toks: &[Token], _src: &[char]) -> Option<Lint> {
let pronoun = &toks[2];
let span = pronoun.span;
diff --git a/harper-core/src/linting/of_course.rs b/harper-core/src/linting/of_course.rs
index 6f6bacdfc..9f69b07e4 100644
--- a/harper-core/src/linting/of_course.rs
+++ b/harper-core/src/linting/of_course.rs
@@ -30,7 +30,7 @@ impl PatternLinter for OfCourse {
fn match_to_lint(&self, matched: &[Token], source: &[char]) -> Option<Lint> {
// Skip if the word before “of” is “kind” or “sort” → “kind of curse” is valid.
if let Some(of_idx) = matched.first().map(|t| t.span.start) {
- if let Some(prev) = source.get(..of_idx).and_then(|src| {
+ match source.get(..of_idx).map(|src| {
// Walk backwards over whitespace to find the preceding word token.
let mut i = of_idx.saturating_sub(1);
while i > 0 && src[i].is_whitespace() {
@@ -42,12 +42,15 @@ impl PatternLinter for OfCourse {
.rposition(|c| c.is_whitespace())
.map(|p| p + 1)
.unwrap_or(0);
- Some(src[start..=i].iter().collect::<String>())
+ src[start..=i].iter().collect::<String>()
}) {
- let lower = prev.to_ascii_lowercase();
- if lower == "kind" || lower == "sort" {
- return None;
+ Some(prev) => {
+ let lower = prev.to_ascii_lowercase();
+ if lower == "kind" || lower == "sort" {
+ return None;
+ }
}
+ _ => (),
}
}