1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

clippy: simplify code according to nightly 'needless_borrows_for_generic_args' lint

https://rust-lang.github.io/rust-clippy/master/index.html#/needless_borrows_for_generic_args
This commit is contained in:
Ben Wiederhake 2024-07-18 15:38:10 +02:00
parent 76af976e48
commit 42b3baf32f
9 changed files with 27 additions and 27 deletions

View file

@ -2028,7 +2028,7 @@ fn test_cp_archive_recursive() {
let result = scene2 let result = scene2
.cmd("ls") .cmd("ls")
.arg("-al") .arg("-al")
.arg(&at.subdir.join(TEST_COPY_TO_FOLDER)) .arg(at.subdir.join(TEST_COPY_TO_FOLDER))
.run(); .run();
println!("ls dest {}", result.stdout_str()); println!("ls dest {}", result.stdout_str());
@ -2036,7 +2036,7 @@ fn test_cp_archive_recursive() {
let result = scene2 let result = scene2
.cmd("ls") .cmd("ls")
.arg("-al") .arg("-al")
.arg(&at.subdir.join(TEST_COPY_TO_FOLDER_NEW)) .arg(at.subdir.join(TEST_COPY_TO_FOLDER_NEW))
.run(); .run();
println!("ls dest {}", result.stdout_str()); println!("ls dest {}", result.stdout_str());

View file

@ -962,7 +962,7 @@ fn test_install_dir() {
at.mkdir(dir); at.mkdir(dir);
ucmd.arg(file1) ucmd.arg(file1)
.arg(file2) .arg(file2)
.arg(&format!("--target-directory={dir}")) .arg(format!("--target-directory={dir}"))
.succeeds() .succeeds()
.no_stderr(); .no_stderr();

View file

@ -335,7 +335,7 @@ fn wrong_line_order() {
.arg("fields_4.txt") .arg("fields_4.txt")
.fails() .fails()
.stdout_contains("7 g f 4 fg") .stdout_contains("7 g f 4 fg")
.stderr_is(&format!( .stderr_is(format!(
"{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order\n", "{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order\n",
ts.bin_path.to_string_lossy(), ts.bin_path.to_string_lossy(),
ts.util_name ts.util_name
@ -347,7 +347,7 @@ fn wrong_line_order() {
.arg("fields_4.txt") .arg("fields_4.txt")
.fails() .fails()
.stdout_does_not_contain("7 g f 4 fg") .stdout_does_not_contain("7 g f 4 fg")
.stderr_is(&format!( .stderr_is(format!(
"{0}: fields_4.txt:5: is not sorted: 11 g 5 gh\n", "{0}: fields_4.txt:5: is not sorted: 11 g 5 gh\n",
ts.util_name ts.util_name
)); ));
@ -361,7 +361,7 @@ fn both_files_wrong_line_order() {
.arg("fields_5.txt") .arg("fields_5.txt")
.fails() .fails()
.stdout_contains("5 e 3 ef") .stdout_contains("5 e 3 ef")
.stderr_is(&format!( .stderr_is(format!(
"{0} {1}: fields_5.txt:4: is not sorted: 3\n{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order\n", "{0} {1}: fields_5.txt:4: is not sorted: 3\n{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order\n",
ts.bin_path.to_string_lossy(), ts.bin_path.to_string_lossy(),
ts.util_name ts.util_name
@ -373,7 +373,7 @@ fn both_files_wrong_line_order() {
.arg("fields_5.txt") .arg("fields_5.txt")
.fails() .fails()
.stdout_does_not_contain("5 e 3 ef") .stdout_does_not_contain("5 e 3 ef")
.stderr_is(&format!( .stderr_is(format!(
"{0}: fields_5.txt:4: is not sorted: 3\n", "{0}: fields_5.txt:4: is not sorted: 3\n",
ts.util_name ts.util_name
)); ));

View file

@ -75,7 +75,7 @@ fn test_invalid_value_returns_1() {
"--time", "--time",
] { ] {
new_ucmd!() new_ucmd!()
.arg(&format!("{flag}=definitely_invalid_value")) .arg(format!("{flag}=definitely_invalid_value"))
.fails() .fails()
.no_stdout() .no_stdout()
.code_is(1); .code_is(1);
@ -87,7 +87,7 @@ fn test_invalid_value_returns_2() {
// Invalid values to flags *sometimes* result in error code 2: // Invalid values to flags *sometimes* result in error code 2:
for flag in ["--block-size", "--width", "--tab-size"] { for flag in ["--block-size", "--width", "--tab-size"] {
new_ucmd!() new_ucmd!()
.arg(&format!("{flag}=definitely_invalid_value")) .arg(format!("{flag}=definitely_invalid_value"))
.fails() .fails()
.no_stdout() .no_stdout()
.code_is(2); .code_is(2);

View file

@ -133,7 +133,7 @@ fn test_mv_move_file_between_dirs() {
assert!(at.file_exists(format!("{dir1}/{file}"))); assert!(at.file_exists(format!("{dir1}/{file}")));
ucmd.arg(&format!("{dir1}/{file}")) ucmd.arg(format!("{dir1}/{file}"))
.arg(dir2) .arg(dir2)
.succeeds() .succeeds()
.no_stderr(); .no_stderr();

View file

@ -30,9 +30,9 @@ fn test_rm_failed() {
let (_at, mut ucmd) = at_and_ucmd!(); let (_at, mut ucmd) = at_and_ucmd!();
let file = "test_rm_one_file"; // Doesn't exist let file = "test_rm_one_file"; // Doesn't exist
ucmd.arg(file).fails().stderr_contains(&format!( ucmd.arg(file)
"cannot remove '{file}': No such file or directory" .fails()
)); .stderr_contains(format!("cannot remove '{file}': No such file or directory"));
} }
#[test] #[test]
@ -170,7 +170,7 @@ fn test_rm_non_empty_directory() {
ucmd.arg("-d") ucmd.arg("-d")
.arg(dir) .arg(dir)
.fails() .fails()
.stderr_contains(&format!("cannot remove '{dir}': Directory not empty")); .stderr_contains(format!("cannot remove '{dir}': Directory not empty"));
assert!(at.file_exists(file_a)); assert!(at.file_exists(file_a));
assert!(at.dir_exists(dir)); assert!(at.dir_exists(dir));
} }
@ -225,7 +225,7 @@ fn test_rm_directory_without_flag() {
ucmd.arg(dir) ucmd.arg(dir)
.fails() .fails()
.stderr_contains(&format!("cannot remove '{dir}': Is a directory")); .stderr_contains(format!("cannot remove '{dir}': Is a directory"));
} }
#[test] #[test]
@ -289,7 +289,7 @@ fn test_rm_symlink_dir() {
.ucmd() .ucmd()
.arg(link) .arg(link)
.fails() .fails()
.stderr_contains(&format!("cannot remove '{link}': Is a directory")); .stderr_contains(format!("cannot remove '{link}': Is a directory"));
assert!(at.dir_exists(link)); assert!(at.dir_exists(link));
@ -337,7 +337,7 @@ fn test_rm_verbose_slash() {
ucmd.arg("-r") ucmd.arg("-r")
.arg("-f") .arg("-f")
.arg("-v") .arg("-v")
.arg(&format!("{dir}///")) .arg(format!("{dir}///"))
.succeeds() .succeeds()
.stdout_only(format!( .stdout_only(format!(
"removed '{file_a_normalized}'\nremoved directory '{dir}'\n" "removed '{file_a_normalized}'\nremoved directory '{dir}'\n"

View file

@ -143,7 +143,7 @@ fn test_range_repeat_no_overflow_1_max() {
let upper_bound = usize::MAX; let upper_bound = usize::MAX;
let result = new_ucmd!() let result = new_ucmd!()
.arg("-rn1") .arg("-rn1")
.arg(&format!("-i1-{upper_bound}")) .arg(format!("-i1-{upper_bound}"))
.succeeds(); .succeeds();
result.no_stderr(); result.no_stderr();
@ -161,7 +161,7 @@ fn test_range_repeat_no_overflow_0_max_minus_1() {
let upper_bound = usize::MAX - 1; let upper_bound = usize::MAX - 1;
let result = new_ucmd!() let result = new_ucmd!()
.arg("-rn1") .arg("-rn1")
.arg(&format!("-i0-{upper_bound}")) .arg(format!("-i0-{upper_bound}"))
.succeeds(); .succeeds();
result.no_stderr(); result.no_stderr();
@ -179,7 +179,7 @@ fn test_range_permute_no_overflow_1_max() {
let upper_bound = usize::MAX; let upper_bound = usize::MAX;
let result = new_ucmd!() let result = new_ucmd!()
.arg("-n1") .arg("-n1")
.arg(&format!("-i1-{upper_bound}")) .arg(format!("-i1-{upper_bound}"))
.succeeds(); .succeeds();
result.no_stderr(); result.no_stderr();
@ -197,7 +197,7 @@ fn test_range_permute_no_overflow_0_max_minus_1() {
let upper_bound = usize::MAX - 1; let upper_bound = usize::MAX - 1;
let result = new_ucmd!() let result = new_ucmd!()
.arg("-n1") .arg("-n1")
.arg(&format!("-i0-{upper_bound}")) .arg(format!("-i0-{upper_bound}"))
.succeeds(); .succeeds();
result.no_stderr(); result.no_stderr();
@ -218,7 +218,7 @@ fn test_range_permute_no_overflow_0_max() {
let upper_bound = usize::MAX; let upper_bound = usize::MAX;
let result = new_ucmd!() let result = new_ucmd!()
.arg("-n1") .arg("-n1")
.arg(&format!("-i0-{upper_bound}")) .arg(format!("-i0-{upper_bound}"))
.succeeds(); .succeeds();
result.no_stderr(); result.no_stderr();

View file

@ -889,7 +889,7 @@ fn test_dictionary_and_nonprinting_conflicts() {
for restricted_arg in ["d", "i"] { for restricted_arg in ["d", "i"] {
for conflicting_arg in &conflicting_args { for conflicting_arg in &conflicting_args {
new_ucmd!() new_ucmd!()
.arg(&format!("-{restricted_arg}{conflicting_arg}")) .arg(format!("-{restricted_arg}{conflicting_arg}"))
.fails(); .fails();
} }
for conflicting_arg in &conflicting_args { for conflicting_arg in &conflicting_args {
@ -897,7 +897,7 @@ fn test_dictionary_and_nonprinting_conflicts() {
.args(&[ .args(&[
format!("-{restricted_arg}").as_str(), format!("-{restricted_arg}").as_str(),
"-k", "-k",
&format!("1,1{conflicting_arg}"), format!("1,1{conflicting_arg}").as_str(),
]) ])
.succeeds(); .succeeds();
} }

View file

@ -4560,7 +4560,7 @@ fn test_gnu_args_c() {
.arg("-12c") .arg("-12c")
.pipe_in(format!("x{}z", "y".repeat(12))) .pipe_in(format!("x{}z", "y".repeat(12)))
.succeeds() .succeeds()
.stdout_only(&format!("{}z", "y".repeat(11))); .stdout_only(format!("{}z", "y".repeat(11)));
} }
#[test] #[test]
@ -4594,7 +4594,7 @@ fn test_gnu_args_l() {
.arg("-l") .arg("-l")
.pipe_in(format!("x{}z", "y\n".repeat(10))) .pipe_in(format!("x{}z", "y\n".repeat(10)))
.succeeds() .succeeds()
.stdout_only(&format!("{}z", "y\n".repeat(9))); .stdout_only(format!("{}z", "y\n".repeat(9)));
} }
#[test] #[test]
@ -4681,7 +4681,7 @@ fn test_gnu_args_b() {
.arg("-b") .arg("-b")
.pipe_in("x\n".repeat(512 * 10 / 2 + 1)) .pipe_in("x\n".repeat(512 * 10 / 2 + 1))
.succeeds() .succeeds()
.stdout_only(&"x\n".repeat(512 * 10 / 2)); .stdout_only("x\n".repeat(512 * 10 / 2));
} }
#[test] #[test]