diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 57492f1..a67896d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -29,6 +29,7 @@ jobs: with: toolchain: ${{ matrix.rust }} override: true + components: rustfmt, clippy - name: Build run: cargo build --verbose - name: Run tests with all features @@ -49,7 +50,18 @@ jobs: run: cargo fmt --all --check - name: Check clippy if: matrix.rust == 'stable' - run: cargo clippy --all-features --all --verbose + run: cargo clippy --all-features --lib --tests --examples --verbose + - name: Check benchmarks with clippy + if: matrix.rust == 'nightly' + run: cargo clippy --all-features --benches --verbose + - name: Check fuzz tests with clippy + if: matrix.rust == 'stable' + working-directory: fuzz + run: cargo clippy --all-features --all-targets --verbose + - name: Check fuzz tests formatting + if: matrix.rust == 'stable' + working-directory: fuzz + run: cargo fmt --all --check msrv: runs-on: ubuntu-latest steps: diff --git a/benches/bench.rs b/benches/bench.rs index a977156..94c989e 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -7,9 +7,9 @@ use std::fs; use test::Bencher; use unicode_normalization::UnicodeNormalization; -const ASCII: &'static str = "all types of normalized"; -const NFC: &'static str = "Introducci\u{00f3}n a Unicode.pdf"; -const NFD: &'static str = "Introduccio\u{0301}n a Unicode.pdf"; +const ASCII: &str = "all types of normalized"; +const NFC: &str = "Introducci\u{00f3}n a Unicode.pdf"; +const NFD: &str = "Introduccio\u{0301}n a Unicode.pdf"; #[bench] fn bench_is_nfc_ascii(b: &mut Bencher) { diff --git a/fuzz/fuzz_targets/streaming.rs b/fuzz/fuzz_targets/streaming.rs index 9124a6d..b758d72 100644 --- a/fuzz/fuzz_targets/streaming.rs +++ b/fuzz/fuzz_targets/streaming.rs @@ -13,9 +13,9 @@ #[macro_use] extern crate libfuzzer_sys; -use std::str::Chars; use std::cell::RefCell; use std::rc::Rc; +use std::str::Chars; use unicode_normalization::{char::canonical_combining_class, UnicodeNormalization}; const MAX_NONSTARTERS: u32 = 30; @@ -43,8 +43,11 @@ impl<'a> Iterator for Counter<'a> { fuzz_target!(|input: String| { let stream_safe = input.chars().stream_safe().collect::(); - let mut value = Rc::new(RefCell::new(0)); - let counter = Counter { iter: stream_safe.chars(), value: Rc::clone(&mut value) }; + let value = Rc::new(RefCell::new(0)); + let counter = Counter { + iter: stream_safe.chars(), + value: Rc::clone(&value), + }; for _ in counter.nfc() { // Plus 1: The iterator may consume a starter that begins the next sequence. assert!(*value.borrow() <= MAX_NONSTARTERS + 1);