Skip to content

Commit 505da7e

Browse files
authored
Merge pull request #7111 from cakebaker/clippy_fix_errors_rust_1_84
clippy: fix errors introduced with Rust `1.84`
2 parents cef9a2b + 51f4bfa commit 505da7e

File tree

6 files changed

+38
-26
lines changed

6 files changed

+38
-26
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,8 @@ multiple_crate_versions = "allow"
564564
cargo_common_metadata = "allow"
565565
uninlined_format_args = "allow"
566566
missing_panics_doc = "allow"
567+
# TODO remove when https://github.com/rust-lang/rust-clippy/issues/13774 is fixed
568+
large_stack_arrays = "allow"
567569

568570
use_self = "warn"
569571
needless_pass_by_value = "warn"

src/uu/cp/src/cp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ impl Options {
935935
if backup_mode != BackupMode::NoBackup
936936
&& matches
937937
.get_one::<String>(update_control::arguments::OPT_UPDATE)
938-
.map_or(false, |v| v == "none" || v == "none-fail")
938+
.is_some_and(|v| v == "none" || v == "none-fail")
939939
{
940940
return Err(Error::InvalidArgument(
941941
"--backup is mutually exclusive with -n or --update=none-fail".to_string(),

src/uu/cp/src/platform/macos.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub(crate) fn copy_on_write(
6464
// clonefile(2) fails if the destination exists. Remove it and try again. Do not
6565
// bother to check if removal worked because we're going to try to clone again.
6666
// first lets make sure the dest file is not read only
67-
if fs::metadata(dest).map_or(false, |md| !md.permissions().readonly()) {
67+
if fs::metadata(dest).is_ok_and(|md| !md.permissions().readonly()) {
6868
// remove and copy again
6969
// TODO: rewrite this to better match linux behavior
7070
// linux first opens the source file and destination file then uses the file

src/uucore/src/lib/features/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ pub fn path_ends_with_terminator(path: &Path) -> bool {
719719
path.as_os_str()
720720
.encode_wide()
721721
.last()
722-
.map_or(false, |wide| wide == b'/'.into() || wide == b'\\'.into())
722+
.is_some_and(|wide| wide == b'/'.into() || wide == b'\\'.into())
723723
}
724724

725725
/// Checks if the standard input (stdin) is a directory.

tests/by-util/test_cp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,7 +2524,7 @@ fn test_cp_sparse_always_non_empty() {
25242524
const BUFFER_SIZE: usize = 4096 * 16 + 3;
25252525
let (at, mut ucmd) = at_and_ucmd!();
25262526

2527-
let mut buf: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE];
2527+
let mut buf = vec![0; BUFFER_SIZE].into_boxed_slice();
25282528
let blocks_to_touch = [buf.len() / 3, 2 * (buf.len() / 3)];
25292529

25302530
for i in blocks_to_touch {
@@ -2540,7 +2540,7 @@ fn test_cp_sparse_always_non_empty() {
25402540
let touched_block_count =
25412541
blocks_to_touch.len() as u64 * at.metadata("dst_file_sparse").blksize() / 512;
25422542

2543-
assert_eq!(at.read_bytes("dst_file_sparse"), buf);
2543+
assert_eq!(at.read_bytes("dst_file_sparse").into_boxed_slice(), buf);
25442544
assert_eq!(at.metadata("dst_file_sparse").blocks(), touched_block_count);
25452545
}
25462546

tests/by-util/test_ls.rs

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,13 +1096,16 @@ fn test_ls_long() {
10961096
let at = &scene.fixtures;
10971097
at.touch(at.plus_as_string("test-long"));
10981098

1099+
#[cfg(not(windows))]
1100+
let regex = r"[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}.*";
1101+
#[cfg(windows)]
1102+
let regex = r"[-dl](r[w-]x){3}.*";
1103+
1104+
let re = &Regex::new(regex).unwrap();
1105+
10991106
for arg in LONG_ARGS {
11001107
let result = scene.ucmd().arg(arg).arg("test-long").succeeds();
1101-
#[cfg(not(windows))]
1102-
result.stdout_matches(&Regex::new(r"[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}.*").unwrap());
1103-
1104-
#[cfg(windows)]
1105-
result.stdout_matches(&Regex::new(r"[-dl](r[w-]x){3}.*").unwrap());
1108+
result.stdout_matches(re);
11061109
}
11071110
}
11081111

@@ -1115,23 +1118,30 @@ fn test_ls_long_format() {
11151118
at.touch(at.plus_as_string("test-long-dir/test-long-file"));
11161119
at.mkdir(at.plus_as_string("test-long-dir/test-long-dir"));
11171120

1118-
for arg in LONG_ARGS {
1119-
// Assuming sane username do not have spaces within them.
1120-
// A line of the output should be:
1121-
// One of the characters -bcCdDlMnpPsStTx?
1122-
// rwx, with - for missing permissions, thrice.
1123-
// Zero or one "." for indicating a file with security context
1124-
// A number, preceded by column whitespace, and followed by a single space.
1125-
// A username, currently [^ ], followed by column whitespace, twice (or thrice for Hurd).
1126-
// A number, followed by a single space.
1127-
// A month, followed by a single space.
1128-
// A day, preceded by column whitespace, and followed by a single space.
1129-
// Either a year or a time, currently [0-9:]+, preceded by column whitespace,
1130-
// and followed by a single space.
1131-
// Whatever comes after is irrelevant to this specific test.
1132-
scene.ucmd().arg(arg).arg("test-long-dir").succeeds().stdout_matches(&Regex::new(
1121+
// Assuming sane username do not have spaces within them.
1122+
// A line of the output should be:
1123+
// One of the characters -bcCdDlMnpPsStTx?
1124+
// rwx, with - for missing permissions, thrice.
1125+
// Zero or one "." for indicating a file with security context
1126+
// A number, preceded by column whitespace, and followed by a single space.
1127+
// A username, currently [^ ], followed by column whitespace, twice (or thrice for Hurd).
1128+
// A number, followed by a single space.
1129+
// A month, followed by a single space.
1130+
// A day, preceded by column whitespace, and followed by a single space.
1131+
// Either a year or a time, currently [0-9:]+, preceded by column whitespace,
1132+
// and followed by a single space.
1133+
// Whatever comes after is irrelevant to this specific test.
1134+
let re = &Regex::new(
11331135
r"\n[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}\.? +\d+ [^ ]+ +[^ ]+( +[^ ]+)? +\d+ [A-Z][a-z]{2} {0,2}\d{0,2} {0,2}[0-9:]+ "
1134-
).unwrap());
1136+
).unwrap();
1137+
1138+
for arg in LONG_ARGS {
1139+
scene
1140+
.ucmd()
1141+
.arg(arg)
1142+
.arg("test-long-dir")
1143+
.succeeds()
1144+
.stdout_matches(re);
11351145
}
11361146

11371147
// This checks for the line with the .. entry. The uname and group should be digits.

0 commit comments

Comments
 (0)