Skip to content

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

refactor: standardize inline bounds syntax for linters (#3601)

Andrew Dunbar2cedc05ac1df
diff --git a/harper-core/src/linting/did_past.rs b/harper-core/src/linting/did_past.rs
index 3f6b539cb..4f968c212 100644
--- a/harper-core/src/linting/did_past.rs
+++ b/harper-core/src/linting/did_past.rs
@@ -13,10 +13,7 @@ pub struct DidPast<D> {
dict: D,
}
-impl<D> DidPast<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> DidPast<D> {
pub fn new(dict: D) -> Self {
Self {
expr: SequenceExpr::longest_of([
@@ -45,10 +42,7 @@ where
}
}
-impl<D> ExprLinter for DidPast<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> ExprLinter for DidPast<D> {
type Unit = Chunk;
fn description(&self) -> &str {
diff --git a/harper-core/src/linting/disjoint_prefixes.rs b/harper-core/src/linting/disjoint_prefixes.rs
index 3a1882014..f6b4e9a65 100644
--- a/harper-core/src/linting/disjoint_prefixes.rs
+++ b/harper-core/src/linting/disjoint_prefixes.rs
@@ -16,10 +16,7 @@ const OVER_EXCEPTIONS: &[&str] = &["all", "joy", "long", "night", "reading", "st
const UNDER_EXCEPTIONS: &[&str] = &["development", "mine"];
const UP_EXCEPTIONS: &[&str] = &["loading", "right", "state", "time", "trend"];
-impl<D> DisjointPrefixes<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> DisjointPrefixes<D> {
pub fn new(dict: D) -> Self {
Self {
expr: SequenceExpr::word_set(&[
@@ -57,10 +54,7 @@ where
}
}
-impl<D> ExprLinter for DisjointPrefixes<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> ExprLinter for DisjointPrefixes<D> {
type Unit = Chunk;
fn expr(&self) -> &dyn Expr {
diff --git a/harper-core/src/linting/mass_nouns/mass_plurals.rs b/harper-core/src/linting/mass_nouns/mass_plurals.rs
index 84ebe0bf9..455d23b16 100644
--- a/harper-core/src/linting/mass_nouns/mass_plurals.rs
+++ b/harper-core/src/linting/mass_nouns/mass_plurals.rs
@@ -12,10 +12,7 @@ pub struct MassPlurals<D> {
dict: D,
}
-impl<D> MassPlurals<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> MassPlurals<D> {
pub fn new(dict: D) -> Self {
let oov = SequenceExpr::default().then_oov();
let looks_plural = SequenceExpr::with(|tok: &Token, src: &[char]| {
@@ -51,10 +48,7 @@ where
}
}
-impl<D> ExprLinter for MassPlurals<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> ExprLinter for MassPlurals<D> {
type Unit = Chunk;
fn expr(&self) -> &dyn Expr {
diff --git a/harper-core/src/linting/mass_nouns/mod.rs b/harper-core/src/linting/mass_nouns/mod.rs
index 9aecd3731..b4c5e4585 100644
--- a/harper-core/src/linting/mass_nouns/mod.rs
+++ b/harper-core/src/linting/mass_nouns/mod.rs
@@ -16,10 +16,7 @@ pub struct MassNouns<D> {
noun_countability: NounCountability,
}
-impl<D> MassNouns<D>
-where
- D: Dictionary + Clone,
-{
+impl<D: Dictionary + Clone> MassNouns<D> {
pub fn new(dict: D) -> Self {
Self {
mass_plurals: MassPlurals::new(dict.clone()),
@@ -28,10 +25,7 @@ where
}
}
-impl<D> Linter for MassNouns<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> Linter for MassNouns<D> {
fn lint(&mut self, document: &Document) -> Vec<Lint> {
let mut lints = Vec::new();
diff --git a/harper-core/src/linting/more_adjective.rs b/harper-core/src/linting/more_adjective.rs
index 825b8313e..4ed9ad177 100644
--- a/harper-core/src/linting/more_adjective.rs
+++ b/harper-core/src/linting/more_adjective.rs
@@ -13,10 +13,7 @@ pub struct MoreAdjective<D> {
dict: D,
}
-impl<D> MoreAdjective<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> MoreAdjective<D> {
pub fn new(dict: D) -> Self {
Self {
expr: SequenceExpr::word_set(&["more", "most"])
@@ -49,10 +46,7 @@ where
}
}
-impl<D> ExprLinter for MoreAdjective<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> ExprLinter for MoreAdjective<D> {
type Unit = Chunk;
fn expr(&self) -> &dyn Expr {
diff --git a/harper-core/src/linting/possessive_noun.rs b/harper-core/src/linting/possessive_noun.rs
index 522837d85..5a3a54eb7 100644
--- a/harper-core/src/linting/possessive_noun.rs
+++ b/harper-core/src/linting/possessive_noun.rs
@@ -12,10 +12,7 @@ pub struct PossessiveNoun<D> {
dict: D,
}
-impl<D> PossessiveNoun<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> PossessiveNoun<D> {
pub fn new(dict: D) -> Self {
let expr = SequenceExpr::with(UPOSSet::new(&[UPOS::DET, UPOS::PROPN]))
.t_ws()
@@ -44,10 +41,7 @@ where
}
}
-impl<D> ExprLinter for PossessiveNoun<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> ExprLinter for PossessiveNoun<D> {
type Unit = Chunk;
fn expr(&self) -> &dyn Expr {
diff --git a/harper-core/src/linting/pronoun_verb_agreement.rs b/harper-core/src/linting/pronoun_verb_agreement.rs
index 562c31261..c23ad9d63 100644
--- a/harper-core/src/linting/pronoun_verb_agreement.rs
+++ b/harper-core/src/linting/pronoun_verb_agreement.rs
@@ -35,10 +35,7 @@ pub struct PronounVerbAgreement<D> {
dict: D,
}
-impl<D> PronounVerbAgreement<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> PronounVerbAgreement<D> {
pub fn new(dict: D) -> Self {
// TODO: allowing "you" leads to false positives:
// "8 years to give you rewards", "all I can do is give you examples"
@@ -166,10 +163,7 @@ where
}
}
-impl<D> ExprLinter for PronounVerbAgreement<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> ExprLinter for PronounVerbAgreement<D> {
type Unit = Chunk;
fn expr(&self) -> &dyn Expr {
diff --git a/harper-core/src/linting/regular_irregulars.rs b/harper-core/src/linting/regular_irregulars.rs
index 0b9df1806..a6e561982 100644
--- a/harper-core/src/linting/regular_irregulars.rs
+++ b/harper-core/src/linting/regular_irregulars.rs
@@ -14,10 +14,7 @@ pub struct RegularIrregulars<D> {
dict: D,
}
-impl<D> RegularIrregulars<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> RegularIrregulars<D> {
pub fn new(dict: D) -> Self {
Self {
exp: Box::new(|tok: &Token, src: &[char]| {
@@ -37,10 +34,7 @@ where
}
}
-impl<D> ExprLinter for RegularIrregulars<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> ExprLinter for RegularIrregulars<D> {
type Unit = Chunk;
fn description(&self) -> &'static str {
diff --git a/harper-core/src/linting/worth_to_do.rs b/harper-core/src/linting/worth_to_do.rs
index ea57e543d..6be07bee4 100644
--- a/harper-core/src/linting/worth_to_do.rs
+++ b/harper-core/src/linting/worth_to_do.rs
@@ -14,10 +14,7 @@ where
dict: D,
}
-impl<D> WorthToDo<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> WorthToDo<D> {
pub fn new(dict: D) -> Self {
Self {
expr: SequenceExpr::word_seq(&["worth", "to"])
@@ -28,10 +25,7 @@ where
}
}
-impl<D> ExprLinter for WorthToDo<D>
-where
- D: Dictionary,
-{
+impl<D: Dictionary> ExprLinter for WorthToDo<D> {
type Unit = Chunk;
fn expr(&self) -> &dyn Expr {