Fix clippy warnings

This commit is contained in:
David Peter 2021-07-27 08:38:09 +02:00 committed by David Peter
parent db30bfc2b7
commit 2a2126c40a
10 changed files with 34 additions and 34 deletions

View File

@ -1,7 +1,7 @@
name: CICD
env:
MIN_SUPPORTED_RUST_VERSION: "1.40.0"
MIN_SUPPORTED_RUST_VERSION: "1.42.0"
CICD_INTERMEDIATES_DIR: "_cicd-intermediates"
on:

View File

@ -621,7 +621,7 @@ With Rust's package manager [cargo](https://github.com/rust-lang/cargo), you can
```
cargo install fd-find
```
Note that rust version *1.36.0* or later is required.
Note that rust version *1.42.0* or later is required.
### From binaries

View File

@ -5,7 +5,7 @@ use clap::Shell;
include!("src/app.rs");
fn main() {
let min_version = "1.36";
let min_version = "1.42";
match version_check::is_min_version(min_version) {
Some(true) => {}

View File

@ -201,10 +201,7 @@ enum ArgumentTemplate {
impl ArgumentTemplate {
pub fn has_tokens(&self) -> bool {
match self {
ArgumentTemplate::Tokens(_) => true,
_ => false,
}
matches!(self, ArgumentTemplate::Tokens(_))
}
/// Generate an argument from this template. If path_separator is Some, then it will replace

View File

@ -5,9 +5,9 @@ pub enum ExitCode {
KilledBySigint,
}
impl Into<i32> for ExitCode {
fn into(self) -> i32 {
match self {
impl From<ExitCode> for i32 {
fn from(code: ExitCode) -> Self {
match code {
ExitCode::Success => 0,
ExitCode::GeneralError => 1,
ExitCode::KilledBySigint => 130,
@ -16,13 +16,13 @@ impl Into<i32> for ExitCode {
}
impl ExitCode {
fn is_error(&self) -> bool {
*self != ExitCode::Success
fn is_error(self) -> bool {
self != ExitCode::Success
}
}
pub fn merge_exitcodes(results: &[ExitCode]) -> ExitCode {
if results.iter().any(ExitCode::is_error) {
if results.iter().any(|&c| ExitCode::is_error(c)) {
return ExitCode::GeneralError;
}
ExitCode::Success

View File

@ -68,22 +68,22 @@ pub fn is_empty(entry: &walk::DirEntry) -> bool {
}
#[cfg(any(unix, target_os = "redox"))]
pub fn is_socket(ft: &fs::FileType) -> bool {
pub fn is_socket(ft: fs::FileType) -> bool {
ft.is_socket()
}
#[cfg(windows)]
pub fn is_socket(_: &fs::FileType) -> bool {
pub fn is_socket(_: fs::FileType) -> bool {
false
}
#[cfg(any(unix, target_os = "redox"))]
pub fn is_pipe(ft: &fs::FileType) -> bool {
pub fn is_pipe(ft: fs::FileType) -> bool {
ft.is_fifo()
}
#[cfg(windows)]
pub fn is_pipe(_: &fs::FileType) -> bool {
pub fn is_pipe(_: fs::FileType) -> bool {
false
}

View File

@ -331,20 +331,20 @@ fn run() -> Result<ExitCode> {
.value_of("max-depth")
.or_else(|| matches.value_of("rg-depth"))
.or_else(|| matches.value_of("exact-depth"))
.map(|n| usize::from_str_radix(n, 10))
.map(|n| n.parse::<usize>())
.transpose()
.context("Failed to parse argument to --max-depth/--exact-depth")?,
min_depth: matches
.value_of("min-depth")
.or_else(|| matches.value_of("exact-depth"))
.map(|n| usize::from_str_radix(n, 10))
.map(|n| n.parse::<usize>())
.transpose()
.context("Failed to parse argument to --min-depth/--exact-depth")?,
prune: matches.is_present("prune"),
threads: std::cmp::max(
matches
.value_of("threads")
.map(|n| usize::from_str_radix(n, 10))
.map(|n| n.parse::<usize>())
.transpose()
.context("Failed to parse number of threads")?
.map(|n| {
@ -360,7 +360,7 @@ fn run() -> Result<ExitCode> {
),
max_buffer_time: matches
.value_of("max-buffer-time")
.map(|n| u64::from_str_radix(n, 10))
.map(|n| n.parse::<u64>())
.transpose()
.context("Failed to parse max. buffer time argument")?
.map(time::Duration::from_millis),
@ -420,7 +420,7 @@ fn run() -> Result<ExitCode> {
path_separator,
max_results: matches
.value_of("max-results")
.map(|n| usize::from_str_radix(n, 10))
.map(|n| n.parse::<usize>())
.transpose()
.context("Failed to parse --max-results argument")?
.filter(|&n| n > 0)

View File

@ -1,5 +1,5 @@
use std::io::{self, StdoutLock, Write};
use std::path::{Path, PathBuf};
use std::path::Path;
use std::process;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
@ -17,12 +17,12 @@ fn replace_path_separator(path: &str, new_path_separator: &str) -> String {
// TODO: this function is performance critical and can probably be optimized
pub fn print_entry(
stdout: &mut StdoutLock,
entry: &PathBuf,
entry: &Path,
config: &Options,
wants_to_quit: &Arc<AtomicBool>,
) {
let path = if entry.is_absolute() {
entry.as_path()
entry
} else {
strip_current_dir(entry)
};

View File

@ -426,8 +426,8 @@ fn spawn_senders(
if (!file_types.files && entry_type.is_file())
|| (!file_types.directories && entry_type.is_dir())
|| (!file_types.symlinks && entry_type.is_symlink())
|| (!file_types.sockets && filesystem::is_socket(entry_type))
|| (!file_types.pipes && filesystem::is_pipe(entry_type))
|| (!file_types.sockets && filesystem::is_socket(*entry_type))
|| (!file_types.pipes && filesystem::is_pipe(*entry_type))
|| (file_types.executables_only
&& !entry
.metadata()
@ -437,8 +437,8 @@ fn spawn_senders(
|| !(entry_type.is_file()
|| entry_type.is_dir()
|| entry_type.is_symlink()
|| filesystem::is_socket(entry_type)
|| filesystem::is_pipe(entry_type))
|| filesystem::is_socket(*entry_type)
|| filesystem::is_pipe(*entry_type))
{
return ignore::WalkState::Continue;
}

View File

@ -119,7 +119,7 @@ fn normalize_output(s: &str, trim_start: bool, normalize_line: bool) -> String {
let line = line.replace('/', &std::path::MAIN_SEPARATOR.to_string());
if normalize_line {
let mut words: Vec<_> = line.split_whitespace().collect();
words.sort();
words.sort_unstable();
return words.join(" ");
}
line
@ -197,7 +197,7 @@ impl TestEnv {
// Check for exit status.
if !output.status.success() {
panic!(format_exit_error(args, &output));
panic!("{}", format_exit_error(args, &output));
}
output
@ -236,7 +236,7 @@ impl TestEnv {
// Compare actual output to expected output.
if expected != actual {
panic!(format_output_error(args, &expected, &actual));
panic!("{}", format_output_error(args, &expected, &actual));
}
}
@ -289,10 +289,13 @@ impl TestEnv {
// Compare actual output to expected output.
if !actual_err.trim_start().starts_with(&expected_error) {
panic!(format_output_error(args, &expected_error, &actual_err));
panic!(
"{}",
format_output_error(args, &expected_error, &actual_err)
);
}
}
return output.status;
output.status
}
}