1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-15 11:36:16 +00:00

Merge pull request #5182 from sylvestre/clippy_

Fix some of the recent clippy warnings
This commit is contained in:
Sylvestre Ledru 2023-08-21 16:21:02 -04:00 committed by GitHub
commit 0b9c829bce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 54 additions and 58 deletions

View file

@ -2026,12 +2026,12 @@ fn test_cp_reflink_always_override() {
const USERDIR: &str = "dir/";
const MOUNTPOINT: &str = "mountpoint/";
let src1_path: &str = &vec![MOUNTPOINT, USERDIR, "src1"].concat();
let src2_path: &str = &vec![MOUNTPOINT, USERDIR, "src2"].concat();
let dst_path: &str = &vec![MOUNTPOINT, USERDIR, "dst"].concat();
let src1_path: &str = &[MOUNTPOINT, USERDIR, "src1"].concat();
let src2_path: &str = &[MOUNTPOINT, USERDIR, "src2"].concat();
let dst_path: &str = &[MOUNTPOINT, USERDIR, "dst"].concat();
scene.fixtures.mkdir(ROOTDIR);
scene.fixtures.mkdir(vec![ROOTDIR, USERDIR].concat());
scene.fixtures.mkdir([ROOTDIR, USERDIR].concat());
// Setup:
// Because neither `mkfs.btrfs` not btrfs `mount` options allow us to have a mountpoint owned

View file

@ -171,7 +171,6 @@ fn test_random() {
break;
}
}
let factor = factor;
match product.checked_mul(factor) {
Some(p) => {
@ -315,7 +314,7 @@ fn run(input_string: &[u8], output_string: &[u8]) {
fn test_primes_with_exponents() {
let mut input_string = String::new();
let mut output_string = String::new();
for primes in PRIMES_BY_BITS.iter() {
for primes in PRIMES_BY_BITS {
for &prime in *primes {
input_string.push_str(&(format!("{prime} "))[..]);
output_string.push_str(&(format!("{prime}: {prime}\n"))[..]);

View file

@ -62,7 +62,7 @@ fn test_link_one_argument() {
#[test]
fn test_link_three_arguments() {
let (_, mut ucmd) = at_and_ucmd!();
let arguments = vec![
let arguments = [
"test_link_argument1",
"test_link_argument2",
"test_link_argument3",

View file

@ -1282,7 +1282,7 @@ fn test_mv_verbose() {
#[test]
#[cfg(any(target_os = "linux", target_os = "android"))] // mkdir does not support -m on windows. Freebsd doesn't return a permission error either.
#[cfg(features = "mkdir")]
#[cfg(feature = "mkdir")]
fn test_mv_permission_error() {
let scene = TestScenario::new("mkdir");
let folder1 = "bar";

View file

@ -482,7 +482,7 @@ fn test_rm_prompts() {
// Needed for talking with stdin on platforms where CRLF or LF matters
const END_OF_LINE: &str = if cfg!(windows) { "\r\n" } else { "\n" };
let mut answers = vec![
let mut answers = [
"rm: descend into directory 'a'?",
"rm: remove write-protected regular empty file 'a/empty-no-write'?",
"rm: remove symbolic link 'a/slink'?",

View file

@ -75,7 +75,7 @@ fn test_echo() {
#[test]
fn test_head_count() {
let repeat_limit = 5;
let input_seq = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let input_seq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let input = input_seq
.iter()
.map(ToString::to_string)
@ -106,7 +106,7 @@ fn test_head_count() {
#[test]
fn test_repeat() {
let repeat_limit = 15000;
let input_seq = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let input_seq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let input = input_seq
.iter()
.map(ToString::to_string)

View file

@ -541,7 +541,7 @@ impl CmdResult {
let contents = String::from_utf8(read_scenario_fixture(&self.tmpd, file_rel_path)).unwrap();
let possible_values = template_vars.iter().map(|vars| {
let mut contents = contents.clone();
for kv in vars.iter() {
for kv in vars {
contents = contents.replace(&kv.0, &kv.1);
}
contents
@ -2211,12 +2211,12 @@ impl UChild {
let join_handle = thread::spawn(move || {
let mut writer = BufWriter::new(stdin);
match writer.write_all(&content).and_then(|_| writer.flush()) {
match writer.write_all(&content).and_then(|()| writer.flush()) {
Err(error) if !ignore_stdin_write_error => Err(io::Error::new(
io::ErrorKind::Other,
format!("failed to write to stdin of child: {error}"),
)),
Ok(_) | Err(_) => Ok(()),
Ok(()) | Err(_) => Ok(()),
}
});
@ -2263,12 +2263,12 @@ impl UChild {
pub fn try_write_in<T: Into<Vec<u8>>>(&mut self, data: T) -> io::Result<()> {
let stdin = self.raw.stdin.as_mut().unwrap();
match stdin.write_all(&data.into()).and_then(|_| stdin.flush()) {
match stdin.write_all(&data.into()).and_then(|()| stdin.flush()) {
Err(error) if !self.ignore_stdin_write_error => Err(io::Error::new(
io::ErrorKind::Other,
format!("failed to write to stdin of child: {error}"),
)),
Ok(_) | Err(_) => Ok(()),
Ok(()) | Err(_) => Ok(()),
}
}
@ -2505,11 +2505,11 @@ pub fn expected_result(ts: &TestScenario, args: &[&str]) -> std::result::Result<
/// This is a convenience wrapper to run a ucmd with root permissions.
/// It can be used to test programs when being root is needed
/// This runs 'sudo -E --non-interactive target/debug/coreutils util_name args`
/// This runs `sudo -E --non-interactive target/debug/coreutils util_name args`
/// This is primarily designed to run in an environment where whoami is in $path
/// and where non-interactive sudo is possible.
/// To check if i) non-interactive sudo is possible and ii) if sudo works, this runs:
/// 'sudo -E --non-interactive whoami' first.
/// `sudo -E --non-interactive whoami` first.
///
/// This return an `Err()` if run inside CICD because there's no 'sudo'.
///
@ -3279,7 +3279,7 @@ mod tests {
std::assert_eq!(error.to_string(), "kill: Timeout of '0s' reached");
}
Err(error) => panic!("Assertion failed: Expected error with timeout but was: {error}"),
Ok(_) => panic!("Assertion failed: Expected timeout of `try_kill`."),
Ok(()) => panic!("Assertion failed: Expected timeout of `try_kill`."),
}
}