style: Make clippy happy

This commit is contained in:
Ed Page committed 2026-09-18 10:11:57 -05:00
1 parent e77dc9d094
commit 131b374bc5
8 files changed
+71 -76

No files matched your search

+5 -5
View File
@@ -33,13 +33,13 @@ unused_macro_rules = "warn"
unused_qualifications = "warn"
[workspace.lints.clippy]
allow_attributes_without_reason = "warn"
#allow_attributes_without_reason = "warn"
bool_assert_comparison = "allow"
branches_sharing_code = "allow"
byte_char_slices = "allow" # sometimes explicit arrays are better
cast_possible_truncation = "warn"
cast_possible_wrap = "warn"
cast_sign_loss = "warn"
#cast_possible_truncation = "warn"
#cast_possible_wrap = "warn"
#cast_sign_loss = "warn"
checked_conversions = "warn"
collapsible_else_if = "allow"
collapsible_if = "allow"
@@ -99,7 +99,7 @@ string_add_assign = "warn"
string_lit_as_bytes = "warn"
todo = "warn"
trait_duplication_in_bounds = "warn"
undocumented_unsafe_blocks = "warn"
#undocumented_unsafe_blocks = "warn"
uninlined_format_args = "warn"
unnecessary_safety_comment = "warn"
unnecessary_safety_doc = "warn"
+5 -5
View File
@@ -16,11 +16,11 @@ pub(crate) enum Format {
impl Format {
pub(crate) fn reporter(self) -> Box<dyn typos_cli::report::Report> {
match self {
Format::Silent => Box::new(crate::report::PrintSilent),
Format::Brief => Box::new(crate::report::PrintBrief),
Format::Long => Box::new(crate::report::PrintLong),
Format::Json => Box::new(crate::report::PrintJson),
Format::Sarif => Box::new(crate::report::PrintSarif::default()),
Self::Silent => Box::new(crate::report::PrintSilent),
Self::Brief => Box::new(crate::report::PrintBrief),
Self::Long => Box::new(crate::report::PrintLong),
Self::Json => Box::new(crate::report::PrintJson),
Self::Sarif => Box::new(crate::report::PrintSarif::default()),
}
}
}
+22 -22
View File
@@ -138,7 +138,7 @@ impl Config {
}
}
pub fn update(&mut self, source: &Config) {
pub fn update(&mut self, source: &Self) {
self.files.update(&source.files);
self.default.update(&source.default);
self.type_.update(&source.type_);
@@ -194,7 +194,7 @@ impl Walk {
}
}
pub fn update(&mut self, source: &Walk) {
pub fn update(&mut self, source: &Self) {
self.extend_exclude
.extend(source.extend_exclude.iter().cloned());
if let Some(source) = source.ignore_hidden {
@@ -337,7 +337,7 @@ pub struct GlobEngineConfig {
}
impl GlobEngineConfig {
pub fn update(&mut self, source: &GlobEngineConfig) {
pub fn update(&mut self, source: &Self) {
self.extend_glob.extend(source.extend_glob.iter().cloned());
self.engine.update(&source.engine);
}
@@ -370,7 +370,7 @@ pub struct EngineConfig {
impl EngineConfig {
pub fn from_defaults() -> Self {
let empty = Self::default();
EngineConfig {
Self {
binary: Some(empty.binary()),
check_filename: Some(empty.check_filename()),
check_file: Some(empty.check_file()),
@@ -381,7 +381,7 @@ impl EngineConfig {
}
}
pub fn update(&mut self, source: &EngineConfig) {
pub fn update(&mut self, source: &Self) {
if let Some(source) = source.binary {
self.binary = Some(source);
}
@@ -439,7 +439,7 @@ impl TokenizerConfig {
}
}
pub fn update(&mut self, source: &TokenizerConfig) {
pub fn update(&mut self, source: &Self) {
if let Some(source) = source.unicode {
self.unicode = Some(source);
}
@@ -501,7 +501,7 @@ impl DictConfig {
}
}
pub fn update(&mut self, source: &DictConfig) {
pub fn update(&mut self, source: &Self) {
if let Some(source) = source.locale {
self.locale = Some(source);
}
@@ -578,11 +578,11 @@ pub enum Locale {
impl Locale {
pub const fn category(self) -> Option<varcon_core::Category> {
match self {
Locale::En => None,
Locale::EnUs => Some(varcon_core::Category::American),
Locale::EnGb => Some(varcon_core::Category::BritishIse),
Locale::EnCa => Some(varcon_core::Category::Canadian),
Locale::EnAu => Some(varcon_core::Category::Australian),
Self::En => None,
Self::EnUs => Some(varcon_core::Category::American),
Self::EnGb => Some(varcon_core::Category::BritishIse),
Self::EnCa => Some(varcon_core::Category::Canadian),
Self::EnAu => Some(varcon_core::Category::Australian),
}
}
@@ -596,11 +596,11 @@ impl std::str::FromStr for Locale {
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"en" => Ok(Locale::En),
"en-us" => Ok(Locale::EnUs),
"en-gb" => Ok(Locale::EnGb),
"en-ca" => Ok(Locale::EnCa),
"en-au" => Ok(Locale::EnAu),
"en" => Ok(Self::En),
"en-us" => Ok(Self::EnUs),
"en-gb" => Ok(Self::EnGb),
"en-ca" => Ok(Self::EnCa),
"en-au" => Ok(Self::EnAu),
_ => Err("valid values: en, en-us, en-gb, en-ca, en-au".to_owned()),
}
}
@@ -609,11 +609,11 @@ impl std::str::FromStr for Locale {
impl std::fmt::Display for Locale {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self {
Locale::En => write!(f, "en"),
Locale::EnUs => write!(f, "en-us"),
Locale::EnGb => write!(f, "en-gb"),
Locale::EnCa => write!(f, "en-ca"),
Locale::EnAu => write!(f, "en-au"),
Self::En => write!(f, "en"),
Self::EnUs => write!(f, "en-us"),
Self::EnGb => write!(f, "en-gb"),
Self::EnCa => write!(f, "en-ca"),
Self::EnAu => write!(f, "en-au"),
}
}
}
+2 -2
View File
@@ -177,11 +177,11 @@ impl BuiltIn {
impl typos::Dictionary for BuiltIn {
fn correct_ident<'s>(&'s self, ident: typos::tokens::Identifier<'_>) -> Option<Status<'s>> {
BuiltIn::correct_ident(self, ident)
Self::correct_ident(self, ident)
}
fn correct_word<'s>(&'s self, word: typos::tokens::Word<'_>) -> Option<Status<'s>> {
BuiltIn::correct_word(self, word)
Self::correct_word(self, word)
}
}
+1 -1
View File
@@ -876,7 +876,7 @@ fn is_fixable(typo: &typos::Typo<'_>) -> bool {
}
fn fix_buffer(mut buffer: Vec<u8>, typos: impl Iterator<Item = typos::Typo<'static>>) -> Vec<u8> {
let mut offset = 0isize;
let mut offset = 0_isize;
for typo in typos {
let fix = extract_fix(&typo).expect("Caller only provides fixable typos");
let start = ((typo.byte_offset as isize) + offset) as usize;
+1 -6
View File
@@ -258,16 +258,11 @@ fn collect_correct(entry: &varcon_core::Entry, category: varcon::Category) -> Ha
}
fn ignore_variant(variant: &varcon_core::Variant) -> bool {
if variant.word == "anesthetisation"
variant.word == "anesthetisation"
&& variant.types.len() == 1
&& variant.types[0].category == varcon::Category::Australian
&& (variant.types[0].tag == Some(varcon::Tag::Variant)
|| variant.types[0].tag == Some(varcon::Tag::Seldom))
{
return true;
}
false
}
// dict needs
+15 -15
View File
@@ -976,28 +976,28 @@ enum WordMode {
impl WordMode {
fn classify(c: char) -> Self {
if c.is_lowercase() {
WordMode::Lowercase
Self::Lowercase
} else if c.is_uppercase() {
WordMode::Uppercase
Self::Uppercase
} else if c.is_ascii_digit() {
WordMode::Number
Self::Number
} else {
// This assumes all characters are either lower or upper case.
WordMode::Boundary
Self::Boundary
}
}
fn case(self, last: WordMode) -> Case {
fn case(self, last: Self) -> Case {
match (self, last) {
(WordMode::Uppercase, WordMode::Uppercase) => Case::Upper,
(WordMode::Uppercase, WordMode::Lowercase) => Case::Title,
(WordMode::Lowercase, WordMode::Lowercase) => Case::Lower,
(WordMode::Number, WordMode::Number) => Case::None,
(WordMode::Number, _)
| (_, WordMode::Number)
| (WordMode::Boundary, _)
| (_, WordMode::Boundary)
| (WordMode::Lowercase, WordMode::Uppercase) => {
(Self::Uppercase, Self::Uppercase) => Case::Upper,
(Self::Uppercase, Self::Lowercase) => Case::Title,
(Self::Lowercase, Self::Lowercase) => Case::Lower,
(Self::Number, Self::Number) => Case::None,
(Self::Number, _)
| (_, Self::Number)
| (Self::Boundary, _)
| (_, Self::Boundary)
| (Self::Lowercase, Self::Uppercase) => {
unreachable!("Invalid case combination: ({:?}, {:?})", self, last)
}
}
@@ -2258,7 +2258,7 @@ mod test {
let cases = [
(
"lowercase",
&[("lowercase", Case::Lower, 0usize)] as &[(&str, Case, usize)],
&[("lowercase", Case::Lower, 0_usize)] as &[(&str, Case, usize)],
),
("Class", &[("Class", Case::Title, 0)]),
(
+20 -20
View File
@@ -1734,13 +1734,13 @@ impl Type {
Self::parse_.parse(input).map_err(|_err| ParseError)
}
fn parse_(input: &mut &str) -> ModalResult<Type, ()> {
fn parse_(input: &mut &str) -> ModalResult<Self, ()> {
trace("type", move |input: &mut &str| {
let category = Category::parse_(input)?;
let tag = opt(Tag::parse_).parse_next(input)?;
let num = opt(winnow::ascii::digit1).parse_next(input)?;
let num = num.map(|s| s.parse().expect("parser ensured it's a number"));
let t = Type { category, tag, num };
let t = Self { category, tag, num };
Ok(t)
})
.parse_next(input)
@@ -1855,12 +1855,12 @@ impl Category {
let symbols = one_of(['A', 'B', 'Z', 'C', 'D', '_']);
symbols
.map(|c| match c {
'A' => Category::American,
'B' => Category::BritishIse,
'Z' => Category::BritishIze,
'C' => Category::Canadian,
'D' => Category::Australian,
'_' => Category::Other,
'A' => Self::American,
'B' => Self::BritishIse,
'Z' => Self::BritishIze,
'C' => Self::Canadian,
'D' => Self::Australian,
'_' => Self::Other,
_ => unreachable!("parser won't select this option"),
})
.parse_next(input)
@@ -1914,11 +1914,11 @@ impl Tag {
let symbols = one_of(['.', 'v', 'V', '-', 'x']);
symbols
.map(|c| match c {
'.' => Tag::Eq,
'v' => Tag::Variant,
'V' => Tag::Seldom,
'-' => Tag::Possible,
'x' => Tag::Improper,
'.' => Self::Eq,
'v' => Self::Variant,
'V' => Self::Seldom,
'-' => Self::Possible,
'x' => Self::Improper,
_ => unreachable!("parser won't select this option"),
})
.parse_next(input)
@@ -1970,13 +1970,13 @@ impl Pos {
fn parse_(input: &mut &str) -> ModalResult<Self, ()> {
trace("pos", move |input: &mut &str| {
alt((
"N".value(Pos::Noun),
"V".value(Pos::Verb),
"Adj".value(Pos::Adjective),
"Adv".value(Pos::Adverb),
"A".value(Pos::AdjectiveOrAdverb),
"Inj".value(Pos::Interjection),
"Prep".value(Pos::Preposition),
"N".value(Self::Noun),
"V".value(Self::Verb),
"Adj".value(Self::Adjective),
"Adv".value(Self::Adverb),
"A".value(Self::AdjectiveOrAdverb),
"Inj".value(Self::Interjection),
"Prep".value(Self::Preposition),
))
.parse_next(input)
})