From bfa6e2316696965bc1bca34b84abb0753498de33 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 12 Aug 2022 07:49:05 +0200 Subject: [PATCH 1/5] numfmt: implement Eq to fix clippy warning --- src/uu/numfmt/src/options.rs | 2 +- src/uu/numfmt/src/units.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/numfmt/src/options.rs b/src/uu/numfmt/src/options.rs index acccf83e52e..0b04d1ef751 100644 --- a/src/uu/numfmt/src/options.rs +++ b/src/uu/numfmt/src/options.rs @@ -74,7 +74,7 @@ impl RoundMethod { } // Represents the options extracted from the --format argument provided by the user. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct FormatOptions { pub grouping: bool, pub padding: Option, diff --git a/src/uu/numfmt/src/units.rs b/src/uu/numfmt/src/units.rs index cd32cfc87a3..08c7e4d3bdd 100644 --- a/src/uu/numfmt/src/units.rs +++ b/src/uu/numfmt/src/units.rs @@ -17,7 +17,7 @@ pub const IEC_BASES: [f64; 10] = [ pub type WithI = bool; -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, Copy, PartialEq, Eq)] pub enum Unit { Auto, Si, From dd19f85d2b3477eb1e5e2bcd6da65540dbef6e1e Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 12 Aug 2022 09:45:16 +0200 Subject: [PATCH 2/5] Fix clippy warnings in tests --- tests/by-util/test_pr.rs | 4 ++-- tests/common/util.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/by-util/test_pr.rs b/tests/by-util/test_pr.rs index cd832cf680e..fdbd1994177 100644 --- a/tests/by-util/test_pr.rs +++ b/tests/by-util/test_pr.rs @@ -404,8 +404,8 @@ fn test_with_pr_core_utils_tests() { for test_case in test_cases { let (flags, input_file, expected_file, return_code) = test_case; let mut scenario = new_ucmd!(); - let input_file_path = input_file.get(0).unwrap(); - let test_file_path = expected_file.get(0).unwrap(); + let input_file_path = input_file.first().unwrap(); + let test_file_path = expected_file.first().unwrap(); let value = file_last_modified_time(&scenario, test_file_path); let mut arguments: Vec<&str> = flags .split(' ') diff --git a/tests/common/util.rs b/tests/common/util.rs index b8119ce4855..93c7e3d12d8 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -982,7 +982,7 @@ impl UCommand { tmpd: Rc, env_clear: bool, ) -> Self { - let tmpd_path_buf = String::from(&(*tmpd.as_ref().path().to_str().unwrap())); + let tmpd_path_buf = String::from(tmpd.as_ref().path().to_str().unwrap()); let mut ucmd: Self = Self::new(bin_path, util_name, tmpd_path_buf, env_clear); ucmd.tmpd = Some(tmpd); ucmd @@ -1296,7 +1296,7 @@ pub fn check_coreutil_version( std::str::from_utf8(&version_check.stdout).unwrap() .split('\n') .collect::>() - .get(0) + .first() .map_or_else( || Err(format!("{}: unexpected output format for reference coreutil: '{} --version'", UUTILS_WARNING, util_name)), |s| { From 898914b6fbc2d72f9a982d3db0a43209b4a5cb1c Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 12 Aug 2022 10:38:14 +0200 Subject: [PATCH 3/5] touch: remove transmute to fix clippy warning --- src/uu/touch/src/touch.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index e8c4fcd2f2d..3a2fca6769b 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -491,7 +491,7 @@ fn pathbuf_from_stdout() -> UResult { // to a u32. let ret = unsafe { GetFinalPathNameByHandleW( - std::mem::transmute(handle), + handle, file_path_buffer.as_mut_ptr(), file_path_buffer.len() as u32, FILE_NAME_OPENED, From 689000576bc64434b2d52ac69ed609895ba3d15a Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 12 Aug 2022 10:18:15 +0200 Subject: [PATCH 4/5] du: remove useless transmute to fix clippy warning --- src/uu/du/src/du.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index 08d4ef0e903..22d229f83f9 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -49,7 +49,7 @@ use winapi::um::minwinbase::{FileIdInfo, FileStandardInfo}; #[cfg(windows)] use winapi::um::winbase::GetFileInformationByHandleEx; #[cfg(windows)] -use winapi::um::winnt::{FILE_ID_128, ULONGLONG}; +use winapi::um::winnt::FILE_ID_128; mod options { pub const HELP: &str = "help"; @@ -254,7 +254,7 @@ fn get_file_info(path: &Path) -> Option { if success != 0 { result = Some(FileInfo { file_id: std::mem::transmute::(file_info.FileId), - dev_id: std::mem::transmute::(file_info.VolumeSerialNumber), + dev_id: file_info.VolumeSerialNumber, }); } } From fcb718527960b5bef4d88d9c71f057ab1b076c3c Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 12 Aug 2022 14:44:23 +0200 Subject: [PATCH 5/5] Disable "broken intra doc links" lint --- src/uucore/src/lib/macros.rs | 4 +++- src/uucore/src/lib/mods/error.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/uucore/src/lib/macros.rs b/src/uucore/src/lib/macros.rs index 255ccd5b33f..cdb3affb5aa 100644 --- a/src/uucore/src/lib/macros.rs +++ b/src/uucore/src/lib/macros.rs @@ -1,3 +1,5 @@ +// TODO fix broken links +#![allow(rustdoc::broken_intra_doc_links)] //! Macros for the uucore utilities. //! //! This module bundles all macros used across the uucore utilities. These @@ -28,7 +30,7 @@ //! - Terminate util execution //! - Crash program: [`crash!`], [`crash_if_err!`] -// spell-checker:ignore sourcepath targetpath +// spell-checker:ignore sourcepath targetpath rustdoc use std::sync::atomic::AtomicBool; diff --git a/src/uucore/src/lib/mods/error.rs b/src/uucore/src/lib/mods/error.rs index 1af6ef7815b..bec76087128 100644 --- a/src/uucore/src/lib/mods/error.rs +++ b/src/uucore/src/lib/mods/error.rs @@ -1,3 +1,5 @@ +// TODO fix broken links +#![allow(rustdoc::broken_intra_doc_links)] //! All utils return exit with an exit code. Usually, the following scheme is used: //! * `0`: succeeded //! * `1`: minor problems @@ -48,7 +50,7 @@ //! * Using [`ExitCode`] is not recommended but can be useful for converting utils to use //! [`UResult`]. -// spell-checker:ignore uioerror +// spell-checker:ignore uioerror rustdoc use clap; use std::{