From b3d5fae1163537079ddd4cd28b7ada03a50131b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gonz=C3=A1lez?= Date: Sat, 15 Apr 2023 16:21:22 +0200 Subject: [PATCH] Fix Clippy lints --- Cargo.toml | 4 ++++ src/lib.rs | 6 ++++-- src/rayon.rs | 1 + tests/flags.rs | 9 +++++---- tests/reduction.rs | 8 ++++---- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7c5f0478..443f81d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,10 @@ name = "oxipng" path = "src/main.rs" required-features = ["binary"] +[[bench]] +name = "zopfli" +required-features = ["zopfli"] + [dependencies] zopfli = { version = "0.7.1", optional = true } rgb = "0.8.33" diff --git a/src/lib.rs b/src/lib.rs index b9606721..0f5b637f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,11 +31,11 @@ use crate::evaluate::Evaluator; use crate::png::PngData; use crate::png::PngImage; use crate::reduction::*; -use log::{debug, error, info, warn}; +use log::{debug, info, warn}; use rayon::prelude::*; use std::fmt; use std::fs::{copy, File, Metadata}; -use std::io::{stdin, stdout, BufWriter, Cursor, Read, Write}; +use std::io::{stdin, stdout, BufWriter, Read, Write}; use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; @@ -1048,6 +1048,8 @@ fn copy_times(input_path_meta: &Metadata, out_path: &Path) -> PngResult<()> { mod sanity_checks { use super::*; use image::{DynamicImage, GenericImageView, ImageFormat, Pixel}; + use log::error; + use std::io::Cursor; /// Validate that the output png data still matches the original image pub(super) fn validate_output(output: &[u8], original_data: &[u8]) -> bool { diff --git a/src/rayon.rs b/src/rayon.rs index 768db04c..ae1914c2 100644 --- a/src/rayon.rs +++ b/src/rayon.rs @@ -52,6 +52,7 @@ where impl ParallelIterator for I {} +#[allow(dead_code)] pub fn join(a: impl FnOnce() -> A, b: impl FnOnce() -> B) -> (A, B) { (a(), b()) } diff --git a/tests/flags.rs b/tests/flags.rs index 38db85b7..fc7ace9e 100644 --- a/tests/flags.rs +++ b/tests/flags.rs @@ -27,6 +27,7 @@ fn get_opts(input: &Path) -> (OutFile, oxipng::Options) { } /// Add callback to allow checks before the output file is deleted again +#[allow(clippy::too_many_arguments)] fn test_it_converts_callbacks( input: PathBuf, output: &OutFile, @@ -38,8 +39,8 @@ fn test_it_converts_callbacks( mut callback_pre: CBPRE, mut callback_post: CBPOST, ) where - CBPOST: FnMut(&Path) -> (), - CBPRE: FnMut(&Path) -> (), + CBPOST: FnMut(&Path), + CBPRE: FnMut(&Path), { let png = PngData::new(&input, opts.fix_errors).unwrap(); @@ -48,14 +49,14 @@ fn test_it_converts_callbacks( callback_pre(&input); - match oxipng::optimize(&InFile::Path(input), &output, &opts) { + match oxipng::optimize(&InFile::Path(input), output, opts) { Ok(_) => (), Err(x) => panic!("{}", x), }; let output = output.path().unwrap(); assert!(output.exists()); - callback_post(&output); + callback_post(output); let png = match PngData::new(output, opts.fix_errors) { Ok(x) => x, diff --git a/tests/reduction.rs b/tests/reduction.rs index f3afdb88..d88cc58c 100644 --- a/tests/reduction.rs +++ b/tests/reduction.rs @@ -834,7 +834,7 @@ fn small_files() { let png = match PngData::new(output, opts.fix_errors) { Ok(x) => x, Err(x) => { - remove_file(&output).ok(); + remove_file(output).ok(); panic!("{}", x) } }; @@ -866,7 +866,7 @@ fn palette_should_be_reduced_with_dupes() { let png = match PngData::new(output, opts.fix_errors) { Ok(x) => x, Err(x) => { - remove_file(&output).ok(); + remove_file(output).ok(); panic!("{}", x) } }; @@ -899,7 +899,7 @@ fn palette_should_be_reduced_with_unused() { let png = match PngData::new(output, opts.fix_errors) { Ok(x) => x, Err(x) => { - remove_file(&output).ok(); + remove_file(output).ok(); panic!("{}", x) } }; @@ -932,7 +932,7 @@ fn palette_should_be_reduced_with_both() { let png = match PngData::new(output, opts.fix_errors) { Ok(x) => x, Err(x) => { - remove_file(&output).ok(); + remove_file(output).ok(); panic!("{}", x) } };