diff --git a/Cargo.toml b/Cargo.toml index ea51f6f99e2..2b62476f518 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -564,6 +564,8 @@ multiple_crate_versions = "allow" cargo_common_metadata = "allow" uninlined_format_args = "allow" missing_panics_doc = "allow" +# TODO remove when https://github.com/rust-lang/rust-clippy/issues/13774 is fixed +large_stack_arrays = "allow" use_self = "warn" needless_pass_by_value = "warn" diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index b87898c783e..f3bded69ef1 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -935,7 +935,7 @@ impl Options { if backup_mode != BackupMode::NoBackup && matches .get_one::(update_control::arguments::OPT_UPDATE) - .map_or(false, |v| v == "none" || v == "none-fail") + .is_some_and(|v| v == "none" || v == "none-fail") { return Err(Error::InvalidArgument( "--backup is mutually exclusive with -n or --update=none-fail".to_string(), diff --git a/src/uu/cp/src/platform/macos.rs b/src/uu/cp/src/platform/macos.rs index 77bdbbbdb83..bd47c44ae96 100644 --- a/src/uu/cp/src/platform/macos.rs +++ b/src/uu/cp/src/platform/macos.rs @@ -64,7 +64,7 @@ pub(crate) fn copy_on_write( // clonefile(2) fails if the destination exists. Remove it and try again. Do not // bother to check if removal worked because we're going to try to clone again. // first lets make sure the dest file is not read only - if fs::metadata(dest).map_or(false, |md| !md.permissions().readonly()) { + if fs::metadata(dest).is_ok_and(|md| !md.permissions().readonly()) { // remove and copy again // TODO: rewrite this to better match linux behavior // linux first opens the source file and destination file then uses the file diff --git a/src/uucore/src/lib/features/fs.rs b/src/uucore/src/lib/features/fs.rs index e2958232f1f..d0875f78a91 100644 --- a/src/uucore/src/lib/features/fs.rs +++ b/src/uucore/src/lib/features/fs.rs @@ -719,7 +719,7 @@ pub fn path_ends_with_terminator(path: &Path) -> bool { path.as_os_str() .encode_wide() .last() - .map_or(false, |wide| wide == b'/'.into() || wide == b'\\'.into()) + .is_some_and(|wide| wide == b'/'.into() || wide == b'\\'.into()) } /// Checks if the standard input (stdin) is a directory. diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 2132b93636f..babd4885529 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -2524,7 +2524,7 @@ fn test_cp_sparse_always_non_empty() { const BUFFER_SIZE: usize = 4096 * 16 + 3; let (at, mut ucmd) = at_and_ucmd!(); - let mut buf: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE]; + let mut buf = vec![0; BUFFER_SIZE].into_boxed_slice(); let blocks_to_touch = [buf.len() / 3, 2 * (buf.len() / 3)]; for i in blocks_to_touch { @@ -2540,7 +2540,7 @@ fn test_cp_sparse_always_non_empty() { let touched_block_count = blocks_to_touch.len() as u64 * at.metadata("dst_file_sparse").blksize() / 512; - assert_eq!(at.read_bytes("dst_file_sparse"), buf); + assert_eq!(at.read_bytes("dst_file_sparse").into_boxed_slice(), buf); assert_eq!(at.metadata("dst_file_sparse").blocks(), touched_block_count); } diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 88ca08320c4..6ef7ac93a2e 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -1096,13 +1096,16 @@ fn test_ls_long() { let at = &scene.fixtures; at.touch(at.plus_as_string("test-long")); + #[cfg(not(windows))] + let regex = r"[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}.*"; + #[cfg(windows)] + let regex = r"[-dl](r[w-]x){3}.*"; + + let re = &Regex::new(regex).unwrap(); + for arg in LONG_ARGS { let result = scene.ucmd().arg(arg).arg("test-long").succeeds(); - #[cfg(not(windows))] - result.stdout_matches(&Regex::new(r"[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}.*").unwrap()); - - #[cfg(windows)] - result.stdout_matches(&Regex::new(r"[-dl](r[w-]x){3}.*").unwrap()); + result.stdout_matches(re); } } @@ -1115,23 +1118,30 @@ fn test_ls_long_format() { at.touch(at.plus_as_string("test-long-dir/test-long-file")); at.mkdir(at.plus_as_string("test-long-dir/test-long-dir")); - for arg in LONG_ARGS { - // Assuming sane username do not have spaces within them. - // A line of the output should be: - // One of the characters -bcCdDlMnpPsStTx? - // rwx, with - for missing permissions, thrice. - // Zero or one "." for indicating a file with security context - // A number, preceded by column whitespace, and followed by a single space. - // A username, currently [^ ], followed by column whitespace, twice (or thrice for Hurd). - // A number, followed by a single space. - // A month, followed by a single space. - // A day, preceded by column whitespace, and followed by a single space. - // Either a year or a time, currently [0-9:]+, preceded by column whitespace, - // and followed by a single space. - // Whatever comes after is irrelevant to this specific test. - scene.ucmd().arg(arg).arg("test-long-dir").succeeds().stdout_matches(&Regex::new( + // Assuming sane username do not have spaces within them. + // A line of the output should be: + // One of the characters -bcCdDlMnpPsStTx? + // rwx, with - for missing permissions, thrice. + // Zero or one "." for indicating a file with security context + // A number, preceded by column whitespace, and followed by a single space. + // A username, currently [^ ], followed by column whitespace, twice (or thrice for Hurd). + // A number, followed by a single space. + // A month, followed by a single space. + // A day, preceded by column whitespace, and followed by a single space. + // Either a year or a time, currently [0-9:]+, preceded by column whitespace, + // and followed by a single space. + // Whatever comes after is irrelevant to this specific test. + let re = &Regex::new( r"\n[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}\.? +\d+ [^ ]+ +[^ ]+( +[^ ]+)? +\d+ [A-Z][a-z]{2} {0,2}\d{0,2} {0,2}[0-9:]+ " - ).unwrap()); + ).unwrap(); + + for arg in LONG_ARGS { + scene + .ucmd() + .arg(arg) + .arg("test-long-dir") + .succeeds() + .stdout_matches(re); } // This checks for the line with the .. entry. The uname and group should be digits.