diff --git a/benches/benchmarks/iter_with_large_setup.rs b/benches/benchmarks/iter_with_large_setup.rs index 217d2715..b4d53ab5 100644 --- a/benches/benchmarks/iter_with_large_setup.rs +++ b/benches/benchmarks/iter_with_large_setup.rs @@ -10,10 +10,7 @@ fn large_setup(c: &mut Criterion) { "iter_with_large_setup", Benchmark::new("large_setup", |b| { // NOTE: iter_with_large_setup is deprecated. Use iter_batched instead. - b.iter_with_large_setup( - || (0..SIZE).map(|i| i as u8).collect::<Vec<_>>(), - |v| v.clone(), - ) + b.iter_with_large_setup(|| (0..SIZE).map(|i| i as u8).collect::<Vec<_>>(), |v| v) }) .throughput(Throughput::Bytes(SIZE as u64)), ); diff --git a/benches/benchmarks/iter_with_setup.rs b/benches/benchmarks/iter_with_setup.rs index 0f870634..e65495ca 100644 --- a/benches/benchmarks/iter_with_setup.rs +++ b/benches/benchmarks/iter_with_setup.rs @@ -4,10 +4,7 @@ const SIZE: usize = 1024 * 1024; fn setup(c: &mut Criterion) { c.bench_function("iter_with_setup", |b| { - b.iter_with_setup( - || (0..SIZE).map(|i| i as u8).collect::<Vec<_>>(), - |v| v.clone(), - ) + b.iter_with_setup(|| (0..SIZE).map(|i| i as u8).collect::<Vec<_>>(), |v| v) }); } diff --git a/plot/src/axis.rs b/plot/src/axis.rs index 97fd0cbe..142c7fbd 100644 --- a/plot/src/axis.rs +++ b/plot/src/axis.rs @@ -155,6 +155,9 @@ where } impl<'a> Script for (Axis, &'a Properties) { + // Allow clippy::format_push_string even with older versions of rust (<1.62) which + // don't have it defined. + #[allow(clippy::all)] fn script(&self) -> String { let &(axis, properties) = self; let axis_ = axis.display(); diff --git a/plot/src/candlestick.rs b/plot/src/candlestick.rs index e0a5cbeb..d1754e8c 100644 --- a/plot/src/candlestick.rs +++ b/plot/src/candlestick.rs @@ -27,6 +27,9 @@ impl Default for Properties { } impl Script for Properties { + // Allow clippy::format_push_string even with older versions of rust (<1.62) which + // don't have it defined. + #[allow(clippy::all)] fn script(&self) -> String { let mut script = String::from("with candlesticks "); diff --git a/plot/src/curve.rs b/plot/src/curve.rs index bbddeff1..a5766ee5 100644 --- a/plot/src/curve.rs +++ b/plot/src/curve.rs @@ -38,6 +38,9 @@ impl CurveDefault<Style> for Properties { } impl Script for Properties { + // Allow clippy::format_push_string even with older versions of rust (<1.62) which + // don't have it defined. + #[allow(clippy::all)] fn script(&self) -> String { let mut script = if let Some(axes) = self.axes { format!("axes {} ", axes.display()) diff --git a/plot/src/errorbar.rs b/plot/src/errorbar.rs index 7efd23e3..f7a823c5 100644 --- a/plot/src/errorbar.rs +++ b/plot/src/errorbar.rs @@ -36,6 +36,9 @@ impl ErrorBarDefault<Style> for Properties { } impl Script for Properties { + // Allow clippy::format_push_string even with older versions of rust (<1.62) which + // don't have it defined. + #[allow(clippy::all)] fn script(&self) -> String { let mut script = format!("with {} ", self.style.display()); diff --git a/plot/src/filledcurve.rs b/plot/src/filledcurve.rs index f79dbddc..ab86099f 100644 --- a/plot/src/filledcurve.rs +++ b/plot/src/filledcurve.rs @@ -27,6 +27,9 @@ impl Default for Properties { } impl Script for Properties { + // Allow clippy::format_push_string even with older versions of rust (<1.62) which + // don't have it defined. + #[allow(clippy::all)] fn script(&self) -> String { let mut script = if let Some(axes) = self.axes { format!("axes {} ", axes.display()) diff --git a/plot/src/key.rs b/plot/src/key.rs index e8847d69..dc27755e 100644 --- a/plot/src/key.rs +++ b/plot/src/key.rs @@ -48,6 +48,9 @@ impl Properties { } impl Script for Properties { + // Allow clippy::format_push_string even with older versions of rust (<1.62) which + // don't have it defined. + #[allow(clippy::all)] fn script(&self) -> String { let mut script = if self.hidden { return String::from("set key off\n"); diff --git a/plot/src/lib.rs b/plot/src/lib.rs index 0ba04dc8..864c4531 100644 --- a/plot/src/lib.rs +++ b/plot/src/lib.rs @@ -438,6 +438,9 @@ impl Figure { } } + // Allow clippy::format_push_string even with older versions of rust (<1.62) which + // don't have it defined. + #[allow(clippy::all)] fn script(&self) -> Vec<u8> { let mut s = String::new(); diff --git a/src/benchmark.rs b/src/benchmark.rs index 0f1f806b..fccb791f 100644 --- a/src/benchmark.rs +++ b/src/benchmark.rs @@ -64,6 +64,7 @@ pub(crate) struct NamedRoutine<T, M: Measurement = WallTime> { /// Structure representing a benchmark (or group of benchmarks) /// which take one parameter. #[doc(hidden)] +#[allow(clippy::type_complexity)] #[deprecated(since = "0.3.4", note = "Please use BenchmarkGroups instead.")] pub struct ParameterizedBenchmark<T: Debug, M: Measurement = WallTime> { config: PartialBenchmarkConfig, @@ -553,7 +554,7 @@ fn execute_benchmark<T, M>( T: Debug, M: Measurement, { - match c.mode { + match &c.mode { Mode::Benchmark => { if let Some(conn) = &c.connection { if do_run { @@ -590,7 +591,7 @@ fn execute_benchmark<T, M>( c.report.test_pass(id, report_context); } } - Mode::Profile(duration) => { + &Mode::Profile(duration) => { if do_run { routine.profile(&c.measurement, id, c, report_context, duration, parameter); } diff --git a/src/benchmark_group.rs b/src/benchmark_group.rs index 9ab535b9..9ed88ef1 100644 --- a/src/benchmark_group.rs +++ b/src/benchmark_group.rs @@ -304,7 +304,7 @@ impl<'a, M: Measurement> BenchmarkGroup<'a, M> { self.any_matched |= do_run; let mut func = Function::new(f); - match self.criterion.mode { + match &self.criterion.mode { Mode::Benchmark => { if let Some(conn) = &self.criterion.connection { if do_run { @@ -340,7 +340,7 @@ impl<'a, M: Measurement> BenchmarkGroup<'a, M> { self.criterion.report.test_pass(&id, &report_context); } } - Mode::Profile(duration) => { + &Mode::Profile(duration) => { if do_run { func.profile( &self.criterion.measurement, diff --git a/src/connection.rs b/src/connection.rs index 0adf20f7..53ad16da 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -358,7 +358,7 @@ impl From<&crate::benchmark::BenchmarkConfig> for BenchmarkConfig { } /// Currently not used; defined for forwards compatibility with cargo-criterion. -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub enum SamplingMethod { Linear, Flat, diff --git a/src/lib.rs b/src/lib.rs index e4de765a..5ccf945d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1063,8 +1063,8 @@ https://bheisler.github.io/criterion.rs/book/faq.html } fn filter_matches(&self, id: &str) -> bool { - match self.filter { - Some(ref regex) => regex.is_match(id), + match &self.filter { + Some(regex) => regex.is_match(id), None => true, } } @@ -1331,7 +1331,7 @@ impl DurationExt for Duration { /// If the throughput setting is configured for a benchmark then the estimated throughput will /// be reported as well as the time per iteration. // TODO: Remove serialize/deserialize from the public API. -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub enum Throughput { /// Measure throughput in terms of bytes/second. The value should be the number of bytes /// processed by one iteration of the benchmarked code. Typically, this would be the length of diff --git a/src/plot/plotters_backend/summary.rs b/src/plot/plotters_backend/summary.rs index d967828a..a5a410d6 100644 --- a/src/plot/plotters_backend/summary.rs +++ b/src/plot/plotters_backend/summary.rs @@ -97,7 +97,6 @@ fn draw_line_comarision_figure<XR: AsRangedCoord<Value = f64>, YR: AsRangedCoord ) .unwrap(); if let Some(name) = name { - let name: &str = &*name; series.label(name).legend(move |(x, y)| { Rectangle::new( [(x, y - 5), (x + 20, y + 5)], diff --git a/src/report.rs b/src/report.rs index 60a144a2..9032a38e 100644 --- a/src/report.rs +++ b/src/report.rs @@ -58,7 +58,7 @@ pub enum ValueType { Value, } -#[derive(Clone, Serialize, Deserialize, PartialEq)] +#[derive(Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct BenchmarkId { pub group_id: String, pub function_id: Option<String>, @@ -828,7 +828,7 @@ mod test { assert_eq!("group/function/value_2", new_id.as_directory_name()); directories.insert(new_id.as_directory_name().to_owned()); - new_id = existing_id.clone(); + new_id = existing_id; new_id.ensure_directory_name_unique(&directories); assert_eq!("group/function/value_3", new_id.as_directory_name()); directories.insert(new_id.as_directory_name().to_owned());