Skip to content

Commit

Permalink
Apply clippy suggestions for rust-1.62 (#591)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemmih authored Jul 2, 2022
1 parent 614236b commit 81ed3cc
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 19 deletions.
5 changes: 1 addition & 4 deletions benches/benchmarks/iter_with_large_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
);
Expand Down
5 changes: 1 addition & 4 deletions benches/benchmarks/iter_with_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});
}

Expand Down
3 changes: 3 additions & 0 deletions plot/src/axis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions plot/src/candlestick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ");

Expand Down
3 changes: 3 additions & 0 deletions plot/src/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
3 changes: 3 additions & 0 deletions plot/src/errorbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
3 changes: 3 additions & 0 deletions plot/src/filledcurve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
3 changes: 3 additions & 0 deletions plot/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 3 additions & 0 deletions plot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
5 changes: 3 additions & 2 deletions src/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/benchmark_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/plot/plotters_backend/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)],
Expand Down
4 changes: 2 additions & 2 deletions src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 81ed3cc

Please sign in to comment.