From 362328162919e91049458613e5eefc1a528eda5a Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 2 Apr 2024 08:45:01 +1100 Subject: [PATCH 1/3] Remove unnecessary reference clippy emits: error: this expression creates a reference which is immediately dereferenced by the compiler As suggested, remove the reference. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 277e50662..672e0b394 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -754,7 +754,7 @@ mod prelude { impl Deref for MutexGuard<'_, T> { type Target = T; - fn deref(&self) -> &T { &self.lock.deref() } + fn deref(&self) -> &T { self.lock.deref() } } impl DerefMut for MutexGuard<'_, T> { From 597db61a1cd9fb8bdf96b94177d8d9d5f468e8a2 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 2 Apr 2024 08:46:01 +1100 Subject: [PATCH 2/3] Remove explicit lifetime clippy emits: error: the following explicit lifetimes could be elided: 'a As suggested, remove the explicit lifetime. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 672e0b394..e6b999aca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -764,7 +764,7 @@ mod prelude { impl Mutex { pub fn new(inner: T) -> Mutex { Mutex { inner: RefCell::new(inner) } } - pub fn lock<'a>(&'a self) -> LockResult> { + pub fn lock(&self) -> LockResult> { Ok(MutexGuard { lock: self.inner.borrow_mut() }) } } From a410c06b3f1a452f4fa1095558d8f0618ca371af Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 1 Apr 2024 14:58:20 +1100 Subject: [PATCH 3/3] CI: Lint the crate We are not currently running the linter in CI, do so. Lint with three different feature combinations to get reasonable coverage. --- .github/workflows/rust.yml | 6 ++++++ contrib/test.sh | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 333c80d7d..7a50ba319 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -15,6 +15,8 @@ jobs: profile: minimal toolchain: nightly override: true + - name: Install clippy + run: rustup component add clippy - name: Running benchmarks env: DO_BENCH: true @@ -27,6 +29,10 @@ jobs: env: DO_FMT: true run: ./contrib/test.sh + - name: Running linter + env: + DO_LINT: true + run: ./contrib/test.sh Int-tests: name: Integration tests diff --git a/contrib/test.sh b/contrib/test.sh index be50ca451..dad7cb356 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -33,6 +33,14 @@ fi # Defaults / sanity checks cargo test +if [ "$DO_LINT" = true ]; then + clippy="cargo +nightly clippy" + + $clippy --all-features --all-targets -- -D warnings + $clippy --all-targets -- -D warnings + $clippy --no-default-features --features=no-std --all-targets -- -D warnings +fi + if [ "$DO_FEATURE_MATRIX" = true ] then # All features