mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 12:37:49 +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:
commit
505da7e6fb
6 changed files with 38 additions and 26 deletions
|
@ -564,6 +564,8 @@ multiple_crate_versions = "allow"
|
||||||
cargo_common_metadata = "allow"
|
cargo_common_metadata = "allow"
|
||||||
uninlined_format_args = "allow"
|
uninlined_format_args = "allow"
|
||||||
missing_panics_doc = "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"
|
use_self = "warn"
|
||||||
needless_pass_by_value = "warn"
|
needless_pass_by_value = "warn"
|
||||||
|
|
|
@ -935,7 +935,7 @@ impl Options {
|
||||||
if backup_mode != BackupMode::NoBackup
|
if backup_mode != BackupMode::NoBackup
|
||||||
&& matches
|
&& matches
|
||||||
.get_one::<String>(update_control::arguments::OPT_UPDATE)
|
.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(
|
return Err(Error::InvalidArgument(
|
||||||
"--backup is mutually exclusive with -n or --update=none-fail".to_string(),
|
"--backup is mutually exclusive with -n or --update=none-fail".to_string(),
|
||||||
|
|
|
@ -64,7 +64,7 @@ pub(crate) fn copy_on_write(
|
||||||
// clonefile(2) fails if the destination exists. Remove it and try again. Do not
|
// 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.
|
// 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
|
// 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
|
// remove and copy again
|
||||||
// TODO: rewrite this to better match linux behavior
|
// TODO: rewrite this to better match linux behavior
|
||||||
// linux first opens the source file and destination file then uses the file
|
// linux first opens the source file and destination file then uses the file
|
||||||
|
|
|
@ -719,7 +719,7 @@ pub fn path_ends_with_terminator(path: &Path) -> bool {
|
||||||
path.as_os_str()
|
path.as_os_str()
|
||||||
.encode_wide()
|
.encode_wide()
|
||||||
.last()
|
.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.
|
/// Checks if the standard input (stdin) is a directory.
|
||||||
|
|
|
@ -2524,7 +2524,7 @@ fn test_cp_sparse_always_non_empty() {
|
||||||
const BUFFER_SIZE: usize = 4096 * 16 + 3;
|
const BUFFER_SIZE: usize = 4096 * 16 + 3;
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
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)];
|
let blocks_to_touch = [buf.len() / 3, 2 * (buf.len() / 3)];
|
||||||
|
|
||||||
for i in blocks_to_touch {
|
for i in blocks_to_touch {
|
||||||
|
@ -2540,7 +2540,7 @@ fn test_cp_sparse_always_non_empty() {
|
||||||
let touched_block_count =
|
let touched_block_count =
|
||||||
blocks_to_touch.len() as u64 * at.metadata("dst_file_sparse").blksize() / 512;
|
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);
|
assert_eq!(at.metadata("dst_file_sparse").blocks(), touched_block_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1096,13 +1096,16 @@ fn test_ls_long() {
|
||||||
let at = &scene.fixtures;
|
let at = &scene.fixtures;
|
||||||
at.touch(at.plus_as_string("test-long"));
|
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 {
|
for arg in LONG_ARGS {
|
||||||
let result = scene.ucmd().arg(arg).arg("test-long").succeeds();
|
let result = scene.ucmd().arg(arg).arg("test-long").succeeds();
|
||||||
#[cfg(not(windows))]
|
result.stdout_matches(re);
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1115,7 +1118,6 @@ fn test_ls_long_format() {
|
||||||
at.touch(at.plus_as_string("test-long-dir/test-long-file"));
|
at.touch(at.plus_as_string("test-long-dir/test-long-file"));
|
||||||
at.mkdir(at.plus_as_string("test-long-dir/test-long-dir"));
|
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.
|
// Assuming sane username do not have spaces within them.
|
||||||
// A line of the output should be:
|
// A line of the output should be:
|
||||||
// One of the characters -bcCdDlMnpPsStTx?
|
// One of the characters -bcCdDlMnpPsStTx?
|
||||||
|
@ -1129,9 +1131,17 @@ fn test_ls_long_format() {
|
||||||
// Either a year or a time, currently [0-9:]+, preceded by column whitespace,
|
// Either a year or a time, currently [0-9:]+, preceded by column whitespace,
|
||||||
// and followed by a single space.
|
// and followed by a single space.
|
||||||
// Whatever comes after is irrelevant to this specific test.
|
// Whatever comes after is irrelevant to this specific test.
|
||||||
scene.ucmd().arg(arg).arg("test-long-dir").succeeds().stdout_matches(&Regex::new(
|
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:]+ "
|
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.
|
// This checks for the line with the .. entry. The uname and group should be digits.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue