From a8b67a42ec568e95ac9e28c6b0feed3a783be330 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 12 Jun 2024 17:35:56 -0400 Subject: [PATCH 1/2] Fix errors from more recent clippy --- zspell-cli/src/download.rs | 1 + zspell/benches/datastructure.rs | 1 + zspell/benches/dict_integration.rs | 2 ++ zspell/benches/slice_contains.rs | 2 ++ zspell/benches/small_map.rs | 1 + zspell/benches/word_splitter.rs | 2 ++ zspell/build.rs | 1 + zspell/src/dict.rs | 2 +- zspell/src/dict/meta.rs | 2 +- zspell/src/dict/rule.rs | 4 +++- zspell/test-util/src/lib.rs | 2 ++ 11 files changed, 17 insertions(+), 3 deletions(-) diff --git a/zspell-cli/src/download.rs b/zspell-cli/src/download.rs index d3113cb..6a4e51a 100644 --- a/zspell-cli/src/download.rs +++ b/zspell-cli/src/download.rs @@ -113,6 +113,7 @@ fn open_new_file(path: &Path, overwrite: bool) -> anyhow::Result { .write(true) .read(true) .create(true) + .truncate(true) .open(path) .context(format!("unable to open '{fname}' in '{dir}'")) } else { diff --git a/zspell/benches/datastructure.rs b/zspell/benches/datastructure.rs index c0b4564..b7e3101 100644 --- a/zspell/benches/datastructure.rs +++ b/zspell/benches/datastructure.rs @@ -2,6 +2,7 @@ //! might use in our spellchecker #![allow(clippy::disallowed_types)] +#![allow(clippy::incompatible_msrv)] use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::fs::File; diff --git a/zspell/benches/dict_integration.rs b/zspell/benches/dict_integration.rs index 108cb7c..ebeaeca 100644 --- a/zspell/benches/dict_integration.rs +++ b/zspell/benches/dict_integration.rs @@ -1,3 +1,5 @@ +#![allow(clippy::incompatible_msrv)] + use std::fs; use std::hint::black_box; diff --git a/zspell/benches/slice_contains.rs b/zspell/benches/slice_contains.rs index c9af42a..61c8dd0 100644 --- a/zspell/benches/slice_contains.rs +++ b/zspell/benches/slice_contains.rs @@ -1,5 +1,7 @@ //! Benchmark the difference between contains & `binary_search`es, intended +#![allow(clippy::incompatible_msrv)] + use std::hint::black_box; use criterion::{criterion_group, criterion_main, Criterion}; diff --git a/zspell/benches/small_map.rs b/zspell/benches/small_map.rs index 8700bea..d4a256b 100644 --- a/zspell/benches/small_map.rs +++ b/zspell/benches/small_map.rs @@ -16,6 +16,7 @@ //! situ (should only affect compile times) #![allow(clippy::disallowed_types)] +#![allow(clippy::incompatible_msrv)] use std::collections::{BTreeMap, HashMap}; use std::hint::black_box; diff --git a/zspell/benches/word_splitter.rs b/zspell/benches/word_splitter.rs index 36047a1..bf178c3 100644 --- a/zspell/benches/word_splitter.rs +++ b/zspell/benches/word_splitter.rs @@ -1,3 +1,5 @@ +#![allow(clippy::incompatible_msrv)] + use std::hint::black_box; use criterion::{criterion_group, criterion_main, Criterion}; diff --git a/zspell/build.rs b/zspell/build.rs index 80ab3d4..8219c9c 100644 --- a/zspell/build.rs +++ b/zspell/build.rs @@ -79,4 +79,5 @@ fn emit_autocfg() { // check if we have `Box<[T]>: From<&[T: Clone]>` loosened from `T: Copy` (1.71) ac.emit_expression_cfg(PROBE_BOX, "box_from_slice_has_clone_bound"); + println!("cargo:rustc-check-cfg=cfg(box_from_slice_has_clone_bound)"); } diff --git a/zspell/src/dict.rs b/zspell/src/dict.rs index 1f3486f..d04544c 100644 --- a/zspell/src/dict.rs +++ b/zspell/src/dict.rs @@ -303,7 +303,7 @@ impl Dictionary { let mut nosuggest = false; for flag in flags { - if self.affix_flags.get(flag).is_none() { + if !self.affix_flags.contains_key(flag) { // FIXME: we get stuck on compound rules continue; } diff --git a/zspell/src/dict/meta.rs b/zspell/src/dict/meta.rs index 88a0f32..863e143 100644 --- a/zspell/src/dict/meta.rs +++ b/zspell/src/dict/meta.rs @@ -55,7 +55,7 @@ pub enum Source { /// The full rule that created this rule: Arc, /// Index of the relevant pattern within the rule. This could potentially be a reference - /// but that might require a RefCell, and I don't want to risk reference + /// but that might require a `RefCell`, and I don't want to risk reference pat_idx: usize, }, /// This meta came from a .dic file, only contains morphinfo diff --git a/zspell/src/dict/rule.rs b/zspell/src/dict/rule.rs index 12a9871..6535354 100644 --- a/zspell/src/dict/rule.rs +++ b/zspell/src/dict/rule.rs @@ -58,7 +58,9 @@ impl AfxRule { ret.patterns.push(AfxRulePattern { affix: rule.affix.as_str().into(), condition: rule.condition.clone(), - strip: rule.strip.as_ref().map(Arc::clone), + // FIXME: `rule.strip.as_ref().map(Arc::clone)` is more accurate, but flagged by + // clippy + strip: rule.strip.clone(), morph_info, }); } diff --git a/zspell/test-util/src/lib.rs b/zspell/test-util/src/lib.rs index 218ef9b..7e18a4a 100644 --- a/zspell/test-util/src/lib.rs +++ b/zspell/test-util/src/lib.rs @@ -1,5 +1,7 @@ //! Utilities intended to help with test collection + #![forbid(unsafe_code)] +#![allow(clippy::assigning_clones)] use std::collections::BTreeMap; use std::fmt::Write; From 2deff3a2d128b94e534da3fdca1f1858fac7cc0c Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 12 Jun 2024 17:42:55 -0400 Subject: [PATCH 2/2] Use beta rather than stable clippy --- .github/workflows/validation-rust.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validation-rust.yaml b/.github/workflows/validation-rust.yaml index 76dbc38..c336347 100644 --- a/.github/workflows/validation-rust.yaml +++ b/.github/workflows/validation-rust.yaml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@beta with: components: clippy - uses: Swatinem/rust-cache@v2