diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 8f265ae2b..10b9bb9d9 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -23,7 +23,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- - run: RUSTFLAGS="--deny warnings" cargo check ${{ matrix.features }}
+ with:
+ components: clippy
+ - run: RUSTFLAGS="--deny warnings" cargo clippy ${{ matrix.features }}
msrv:
runs-on: ubuntu-latest
diff --git a/Cargo.toml b/Cargo.toml
index f1ffe19cd..9903ed4a9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,6 +15,7 @@ categories = ["algorithms", "rust-patterns"]
edition = "2018"
+# When bumping, please resolve all `#[allow(clippy::*)]` that are newly resolvable.
rust-version = "1.43.1"
[lib]
diff --git a/benches/bench1.rs b/benches/bench1.rs
index b01b8f360..8d8881676 100644
--- a/benches/bench1.rs
+++ b/benches/bench1.rs
@@ -475,6 +475,8 @@ fn merge_default(c: &mut Criterion) {
let mut data1 = vec![0; 1024];
let mut data2 = vec![0; 800];
let mut x = 0;
+
+ #[allow(clippy::explicit_counter_loop, clippy::unused_enumerate_index)]
for (_, elt) in data1.iter_mut().enumerate() {
*elt = x;
x += 1;
@@ -501,6 +503,8 @@ fn merge_by_cmp(c: &mut Criterion) {
let mut data1 = vec![0; 1024];
let mut data2 = vec![0; 800];
let mut x = 0;
+
+ #[allow(clippy::explicit_counter_loop, clippy::unused_enumerate_index)]
for (_, elt) in data1.iter_mut().enumerate() {
*elt = x;
x += 1;
@@ -527,6 +531,8 @@ fn merge_by_lt(c: &mut Criterion) {
let mut data1 = vec![0; 1024];
let mut data2 = vec![0; 800];
let mut x = 0;
+
+ #[allow(clippy::explicit_counter_loop, clippy::unused_enumerate_index)]
for (_, elt) in data1.iter_mut().enumerate() {
*elt = x;
x += 1;
@@ -553,6 +559,8 @@ fn kmerge_default(c: &mut Criterion) {
let mut data1 = vec![0; 1024];
let mut data2 = vec![0; 800];
let mut x = 0;
+
+ #[allow(clippy::explicit_counter_loop, clippy::unused_enumerate_index)]
for (_, elt) in data1.iter_mut().enumerate() {
*elt = x;
x += 1;
@@ -592,7 +600,7 @@ fn kmerge_tenway(c: &mut Criterion) {
let mut chunks = Vec::new();
let mut rest = &mut data[..];
- while rest.len() > 0 {
+ while !rest.is_empty() {
let chunk_len = 1 + rng(&mut state) % 512;
let chunk_len = cmp::min(rest.len(), chunk_len as usize);
let (fst, tail) = { rest }.split_at_mut(chunk_len);
diff --git a/benches/extra/zipslices.rs b/benches/extra/zipslices.rs
index 5476c0cb8..a7120e168 100644
--- a/benches/extra/zipslices.rs
+++ b/benches/extra/zipslices.rs
@@ -138,6 +138,8 @@ where
/// A helper trait to let `ZipSlices` accept both `&[T]` and `&mut [T]`.
///
+/// # Safety
+///
/// Unsafe trait because:
///
/// - Implementors must guarantee that `get_unchecked` is valid for all indices `0..len()`.
diff --git a/benches/fold_specialization.rs b/benches/fold_specialization.rs
index 3a040305b..b44f34721 100644
--- a/benches/fold_specialization.rs
+++ b/benches/fold_specialization.rs
@@ -46,7 +46,10 @@ mod specialization {
let arr = [1; 1024];
c.bench_function("internal specialized", move |b| {
- b.iter(|| arr.iter().intersperse(&0).fold(0, |acc, x| acc + x))
+ b.iter(|| {
+ #[allow(clippy::unnecessary_fold)]
+ arr.iter().intersperse(&0).fold(0, |acc, x| acc + x)
+ })
});
}
@@ -54,7 +57,10 @@ mod specialization {
let arr = [1; 1024];
c.bench_function("internal unspecialized", move |b| {
- b.iter(|| Unspecialized(arr.iter().intersperse(&0)).fold(0, |acc, x| acc + x))
+ b.iter(|| {
+ #[allow(clippy::unnecessary_fold)]
+ Unspecialized(arr.iter().intersperse(&0)).fold(0, |acc, x| acc + x)
+ })
});
}
}
diff --git a/examples/iris.rs b/examples/iris.rs
index af64322d6..798fdb08e 100644
--- a/examples/iris.rs
+++ b/examples/iris.rs
@@ -9,7 +9,7 @@ use std::iter::repeat;
use std::num::ParseFloatError;
use std::str::FromStr;
-static DATA: &'static str = include_str!("iris.data");
+static DATA: &str = include_str!("iris.data");
#[derive(Clone, Debug)]
struct Iris {
@@ -38,7 +38,7 @@ impl FromStr for Iris {
name: "".into(),
data: [0.; 4],
};
- let mut parts = s.split(",").map(str::trim);
+ let mut parts = s.split(',').map(str::trim);
// using Iterator::by_ref()
for (index, part) in parts.by_ref().take(4).enumerate() {
diff --git a/src/adaptors/mod.rs b/src/adaptors/mod.rs
index f622bceda..a5b182d78 100644
--- a/src/adaptors/mod.rs
+++ b/src/adaptors/mod.rs
@@ -607,11 +607,11 @@ where
Some(item) => Ok(f(acc, item)),
None => Err(acc),
});
- let res = match res {
+
+ match res {
Ok(val) => val,
Err(val) => val,
- };
- res
+ }
}
}
diff --git a/src/adaptors/multi_product.rs b/src/adaptors/multi_product.rs
index ef7fadba8..f02f8c740 100644
--- a/src/adaptors/multi_product.rs
+++ b/src/adaptors/multi_product.rs
@@ -220,9 +220,9 @@ where
self.0.iter().fold(
(0, Some(0)),
|acc,
- &MultiProductIter {
- ref iter,
- ref iter_orig,
+ MultiProductIter {
+ iter,
+ iter_orig,
cur: _,
}| {
let cur_size = iter.size_hint();
diff --git a/src/either_or_both.rs b/src/either_or_both.rs
index 9dbc880d3..2232cd68c 100644
--- a/src/either_or_both.rs
+++ b/src/either_or_both.rs
@@ -29,19 +29,13 @@ impl EitherOrBoth {
/// If `Left`, return true. Otherwise, return false.
/// Exclusive version of [`has_left`](EitherOrBoth::has_left).
pub fn is_left(&self) -> bool {
- match *self {
- Left(_) => true,
- _ => false,
- }
+ matches!(self, Left(_))
}
/// If `Right`, return true. Otherwise, return false.
/// Exclusive version of [`has_right`](EitherOrBoth::has_right).
pub fn is_right(&self) -> bool {
- match *self {
- Right(_) => true,
- _ => false,
- }
+ matches!(self, Right(_))
}
/// If `Both`, return true. Otherwise, return false.
@@ -500,6 +494,7 @@ impl EitherOrBoth {
}
}
+#[allow(clippy::from_over_into)]
impl Into