From 3d9a9a0055b7412d5c216b8cc976aea0e99aa20c Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Wed, 10 Jul 2024 15:59:03 +0700 Subject: [PATCH] clippy: Fix `semicolon_if_nothing_returned` lints --- benches/benchmarks/compare_functions.rs | 6 ++-- benches/benchmarks/custom_measurement.rs | 6 ++-- benches/benchmarks/external_process.rs | 2 +- benches/benchmarks/iter_with_large_setup.rs | 4 +-- benches/benchmarks/iter_with_setup.rs | 2 +- benches/benchmarks/measurement_overhead.rs | 14 ++++---- benches/benchmarks/sampling_mode.rs | 6 ++-- src/lib.rs | 2 +- src/plot/plotters_backend/distributions.rs | 6 ++-- src/plot/plotters_backend/summary.rs | 4 +-- src/report.rs | 4 +-- src/stats/univariate/resamples.rs | 4 +-- tests/criterion_tests.rs | 36 ++++++++++----------- 13 files changed, 48 insertions(+), 48 deletions(-) diff --git a/benches/benchmarks/compare_functions.rs b/benches/benchmarks/compare_functions.rs index d9af837a8..c68cb44e0 100644 --- a/benches/benchmarks/compare_functions.rs +++ b/benches/benchmarks/compare_functions.rs @@ -34,13 +34,13 @@ fn compare_fibonaccis_group(c: &mut Criterion) { let mut group = c.benchmark_group("Fibonacci3"); for i in 20..=21 { group.bench_with_input(BenchmarkId::new("Recursive", i), &i, |b, i| { - b.iter(|| fibonacci_slow(*i)) + b.iter(|| fibonacci_slow(*i)); }); group.bench_with_input(BenchmarkId::new("Iterative", i), &i, |b, i| { - b.iter(|| fibonacci_fast(*i)) + b.iter(|| fibonacci_fast(*i)); }); } - group.finish() + group.finish(); } criterion_group!(fibonaccis, compare_fibonaccis, compare_fibonaccis_group,); diff --git a/benches/benchmarks/custom_measurement.rs b/benches/benchmarks/custom_measurement.rs index 449f9030c..e671f3712 100644 --- a/benches/benchmarks/custom_measurement.rs +++ b/benches/benchmarks/custom_measurement.rs @@ -41,14 +41,14 @@ impl ValueFormatter for HalfSecFormatter { match *throughput { Throughput::Bytes(bytes) | Throughput::BytesDecimal(bytes) => { for val in values { - *val = (bytes as f64) / (*val * 2f64 * 10f64.powi(-9)) + *val = (bytes as f64) / (*val * 2f64 * 10f64.powi(-9)); } "b/s/2" } Throughput::Elements(elems) => { for val in values { - *val = (elems as f64) / (*val * 2f64 * 10f64.powi(-9)) + *val = (elems as f64) / (*val * 2f64 * 10f64.powi(-9)); } "elem/s/2" @@ -103,7 +103,7 @@ fn fibonacci_slow(n: u64) -> u64 { fn fibonacci_cycles(criterion: &mut Criterion) { criterion.bench_function("fibonacci_custom_measurement", |bencher| { - bencher.iter(|| fibonacci_slow(black_box(10))) + bencher.iter(|| fibonacci_slow(black_box(10))); }); } diff --git a/benches/benchmarks/external_process.rs b/benches/benchmarks/external_process.rs index 7667a53b8..ffd255870 100644 --- a/benches/benchmarks/external_process.rs +++ b/benches/benchmarks/external_process.rs @@ -47,7 +47,7 @@ fn python_fibonacci(c: &mut Criterion) { let nanoseconds: u64 = u64::from_str(line.trim()).expect("Unable to parse time from child process"); Duration::from_nanos(nanoseconds) - }) + }); }); // Ensure that your child process terminates itself gracefully! diff --git a/benches/benchmarks/iter_with_large_setup.rs b/benches/benchmarks/iter_with_large_setup.rs index 9ff2b9d5d..fda92b030 100644 --- a/benches/benchmarks/iter_with_large_setup.rs +++ b/benches/benchmarks/iter_with_large_setup.rs @@ -11,14 +11,14 @@ fn large_setup(c: &mut Criterion) { || (0..SIZE).map(|i| i as u8).collect::>(), |v| v, BatchSize::NumBatches(1), - ) + ); }); } fn small_setup(c: &mut Criterion) { let mut group = c.benchmark_group("iter_with_large_setup"); group.bench_function("small_setup", |b| { - b.iter_batched(|| SIZE, |size| size, BatchSize::NumBatches(1)) + b.iter_batched(|| SIZE, |size| size, BatchSize::NumBatches(1)); }); } diff --git a/benches/benchmarks/iter_with_setup.rs b/benches/benchmarks/iter_with_setup.rs index e65495ca4..c9b09dc50 100644 --- a/benches/benchmarks/iter_with_setup.rs +++ b/benches/benchmarks/iter_with_setup.rs @@ -4,7 +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::>(), |v| v) + b.iter_with_setup(|| (0..SIZE).map(|i| i as u8).collect::>(), |v| v); }); } diff --git a/benches/benchmarks/measurement_overhead.rs b/benches/benchmarks/measurement_overhead.rs index c424efb01..e4715c724 100644 --- a/benches/benchmarks/measurement_overhead.rs +++ b/benches/benchmarks/measurement_overhead.rs @@ -5,26 +5,26 @@ fn some_benchmark(c: &mut Criterion) { group.bench_function("iter", |b| b.iter(|| 1)); group.bench_function("iter_with_setup", |b| b.iter_with_setup(|| (), |_| 1)); group.bench_function("iter_with_large_setup", |b| { - b.iter_batched(|| (), |_| 1, BatchSize::NumBatches(1)) + b.iter_batched(|| (), |_| 1, BatchSize::NumBatches(1)); }); group.bench_function("iter_with_large_drop", |b| b.iter_with_large_drop(|| 1)); group.bench_function("iter_batched_small_input", |b| { - b.iter_batched(|| (), |_| 1, BatchSize::SmallInput) + b.iter_batched(|| (), |_| 1, BatchSize::SmallInput); }); group.bench_function("iter_batched_large_input", |b| { - b.iter_batched(|| (), |_| 1, BatchSize::LargeInput) + b.iter_batched(|| (), |_| 1, BatchSize::LargeInput); }); group.bench_function("iter_batched_per_iteration", |b| { - b.iter_batched(|| (), |_| 1, BatchSize::PerIteration) + b.iter_batched(|| (), |_| 1, BatchSize::PerIteration); }); group.bench_function("iter_batched_ref_small_input", |b| { - b.iter_batched_ref(|| (), |_| 1, BatchSize::SmallInput) + b.iter_batched_ref(|| (), |_| 1, BatchSize::SmallInput); }); group.bench_function("iter_batched_ref_large_input", |b| { - b.iter_batched_ref(|| (), |_| 1, BatchSize::LargeInput) + b.iter_batched_ref(|| (), |_| 1, BatchSize::LargeInput); }); group.bench_function("iter_batched_ref_per_iteration", |b| { - b.iter_batched_ref(|| (), |_| 1, BatchSize::PerIteration) + b.iter_batched_ref(|| (), |_| 1, BatchSize::PerIteration); }); group.finish(); } diff --git a/benches/benchmarks/sampling_mode.rs b/benches/benchmarks/sampling_mode.rs index c7ac7bfa8..cc4d9d5e7 100644 --- a/benches/benchmarks/sampling_mode.rs +++ b/benches/benchmarks/sampling_mode.rs @@ -7,17 +7,17 @@ fn sampling_mode_tests(c: &mut Criterion) { group.sampling_mode(SamplingMode::Auto); group.bench_function("Auto", |bencher| { - bencher.iter(|| sleep(Duration::from_millis(0))) + bencher.iter(|| sleep(Duration::from_millis(0))); }); group.sampling_mode(SamplingMode::Linear); group.bench_function("Linear", |bencher| { - bencher.iter(|| sleep(Duration::from_millis(0))) + bencher.iter(|| sleep(Duration::from_millis(0))); }); group.sampling_mode(SamplingMode::Flat); group.bench_function("Flat", |bencher| { - bencher.iter(|| sleep(Duration::from_millis(10))) + bencher.iter(|| sleep(Duration::from_millis(10))); }); group.finish(); diff --git a/src/lib.rs b/src/lib.rs index 2f7fa952c..31c61066e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1031,7 +1031,7 @@ https://bheisler.github.io/criterion.rs/book/faq.html if let Some(dir) = matches.get_one::("save-baseline") { self.baseline = Baseline::Save; - dir.clone_into(&mut self.baseline_directory) + dir.clone_into(&mut self.baseline_directory); } if matches.get_flag("discard-baseline") { self.baseline = Baseline::Discard; diff --git a/src/plot/plotters_backend/distributions.rs b/src/plot/plotters_backend/distributions.rs index 04f7d42c8..448caa2f5 100644 --- a/src/plot/plotters_backend/distributions.rs +++ b/src/plot/plotters_backend/distributions.rs @@ -149,8 +149,8 @@ pub(crate) fn abs_distributions( distribution, estimate, size, - ) - }) + ); + }); } fn rel_distribution( @@ -303,6 +303,6 @@ pub(crate) fn rel_distributions( comparison.relative_estimates.get(statistic), comparison.noise_threshold, size, - ) + ); }); } diff --git a/src/plot/plotters_backend/summary.rs b/src/plot/plotters_backend/summary.rs index 267fb1000..4a82577c1 100644 --- a/src/plot/plotters_backend/summary.rs +++ b/src/plot/plotters_backend/summary.rs @@ -41,7 +41,7 @@ pub fn line_comparison( match axis_scale { AxisScale::Linear => { - draw_line_comarision_figure(root_area, unit, x_range, y_range, value_type, series_data) + draw_line_comarision_figure(root_area, unit, x_range, y_range, value_type, series_data); } AxisScale::Logarithmic => draw_line_comarision_figure( root_area, @@ -209,7 +209,7 @@ pub fn violin( match axis_scale { AxisScale::Linear => draw_violin_figure(root_area, unit, x_range, y_range, kdes), AxisScale::Logarithmic => { - draw_violin_figure(root_area, unit, x_range.log_scale(), y_range, kdes) + draw_violin_figure(root_area, unit, x_range.log_scale(), y_range, kdes); } } } diff --git a/src/report.rs b/src/report.rs index 0e14696be..c27bc4860 100644 --- a/src/report.rs +++ b/src/report.rs @@ -395,7 +395,7 @@ impl CliReport { fn text_overwrite(&self) { if self.enable_text_overwrite { - eprint!("\r{}", ClearLine::All) + eprint!("\r{}", ClearLine::All); } } @@ -590,7 +590,7 @@ impl Report for CliReport { throughput, typical_estimate.confidence_interval.lower_bound )), - ) + ); } if !matches!(self.verbosity, CliVerbosity::Quiet) { diff --git a/src/stats/univariate/resamples.rs b/src/stats/univariate/resamples.rs index 33bc5b38e..b3eba6e7f 100644 --- a/src/stats/univariate/resamples.rs +++ b/src/stats/univariate/resamples.rs @@ -38,7 +38,7 @@ where for _ in 0..n { let idx = rng.rand_range(0u64..(self.sample.len() as u64)); - stage.push(self.sample[idx as usize]) + stage.push(self.sample[idx as usize]); } self.stage = Some(stage); @@ -46,7 +46,7 @@ where Some(ref mut stage) => { for elem in stage.iter_mut() { let idx = rng.rand_range(0u64..(self.sample.len() as u64)); - *elem = self.sample[idx as usize] + *elem = self.sample[idx as usize]; } } } diff --git a/tests/criterion_tests.rs b/tests/criterion_tests.rs index 6a009fa5f..52811ff8e 100644 --- a/tests/criterion_tests.rs +++ b/tests/criterion_tests.rs @@ -197,7 +197,7 @@ fn test_sample_size() { .sample_size(50) .bench_function("test_sample_size", move |b| { clone.count(); - b.iter(|| 10) + b.iter(|| 10); }); // This function will be called more than sample_size times because of the @@ -215,7 +215,7 @@ fn test_warmup_time() { .warm_up_time(Duration::from_millis(100)) .bench_function("test_warmup_time_1", move |b| { clone.count(); - b.iter(|| 10) + b.iter(|| 10); }); let counter2 = Counter::default(); @@ -224,7 +224,7 @@ fn test_warmup_time() { .warm_up_time(Duration::from_millis(2000)) .bench_function("test_warmup_time_2", move |b| { clone.count(); - b.iter(|| 10) + b.iter(|| 10); }); assert!(counter1.read() < counter2.read()); @@ -275,43 +275,43 @@ fn test_timing_loops() { let mut c = short_benchmark(&dir); let mut group = c.benchmark_group("test_timing_loops"); group.bench_function("iter_with_setup", |b| { - b.iter_with_setup(|| vec![10], |v| v[0]) + b.iter_with_setup(|| vec![10], |v| v[0]); }); group.bench_function("iter_with_large_setup", |b| { - b.iter_batched(|| vec![10], |v| v[0], BatchSize::NumBatches(1)) + b.iter_batched(|| vec![10], |v| v[0], BatchSize::NumBatches(1)); }); group.bench_function("iter_with_large_drop", |b| { - b.iter_with_large_drop(|| vec![10; 100]) + b.iter_with_large_drop(|| vec![10; 100]); }); group.bench_function("iter_batched_small", |b| { - b.iter_batched(|| vec![10], |v| v[0], BatchSize::SmallInput) + b.iter_batched(|| vec![10], |v| v[0], BatchSize::SmallInput); }); group.bench_function("iter_batched_large", |b| { - b.iter_batched(|| vec![10], |v| v[0], BatchSize::LargeInput) + b.iter_batched(|| vec![10], |v| v[0], BatchSize::LargeInput); }); group.bench_function("iter_batched_per_iteration", |b| { - b.iter_batched(|| vec![10], |v| v[0], BatchSize::PerIteration) + b.iter_batched(|| vec![10], |v| v[0], BatchSize::PerIteration); }); group.bench_function("iter_batched_one_batch", |b| { - b.iter_batched(|| vec![10], |v| v[0], BatchSize::NumBatches(1)) + b.iter_batched(|| vec![10], |v| v[0], BatchSize::NumBatches(1)); }); group.bench_function("iter_batched_10_iterations", |b| { - b.iter_batched(|| vec![10], |v| v[0], BatchSize::NumIterations(10)) + b.iter_batched(|| vec![10], |v| v[0], BatchSize::NumIterations(10)); }); group.bench_function("iter_batched_ref_small", |b| { - b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::SmallInput) + b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::SmallInput); }); group.bench_function("iter_batched_ref_large", |b| { - b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::LargeInput) + b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::LargeInput); }); group.bench_function("iter_batched_ref_per_iteration", |b| { - b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::PerIteration) + b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::PerIteration); }); group.bench_function("iter_batched_ref_one_batch", |b| { - b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::NumBatches(1)) + b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::NumBatches(1)); }); group.bench_function("iter_batched_ref_10_iterations", |b| { - b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::NumIterations(10)) + b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::NumIterations(10)); }); } @@ -461,7 +461,7 @@ fn test_criterion_doesnt_panic_if_measured_time_is_zero() { let dir = temp_dir(); let mut c = short_benchmark(&dir); c.bench_function("zero_time", |bencher| { - bencher.iter_custom(|_iters| Duration::new(0, 0)) + bencher.iter_custom(|_iters| Duration::new(0, 0)); }); } @@ -494,7 +494,7 @@ mod macros { // silence dead_code warning if false { - main() + main(); } }