1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

Merge pull request #7111 from cakebaker/clippy_fix_errors_rust_1_84

clippy: fix errors introduced with Rust `1.84`
This commit is contained in:
Sylvestre Ledru 2025-01-10 09:23:43 +01:00 committed by GitHub
commit 505da7e6fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 38 additions and 26 deletions

View file

@ -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"

View file

@ -935,7 +935,7 @@ impl Options {
if backup_mode != BackupMode::NoBackup
&& matches
.get_one::<String>(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(),

View file

@ -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

View file

@ -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.

View file

@ -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);
}

View file

@ -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.