From d9d97d0299a88eb6e5005927cee3e96e61d015c0 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 11 Jun 2023 13:20:59 +0900 Subject: [PATCH] Fix clippy::needless_borrow warning ``` error: the borrowed expression implements the required traits --> src/lib.rs:212:57 | 212 | signal_hook::iterator::Signals::new(&[signal_hook::consts::SIGCHLD]) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `[signal_hook::consts::SIGCHLD]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `-D clippy::needless-borrow` implied by `-D warnings` error: the borrowed expression implements the required traits --> tests/std.rs:14:38 | 14 | Command::new("cmd").args(&["/C", "exit 0"]).spawn() | ^^^^^^^^^^^^^^^^^ help: change this to: `["/C", "exit 0"]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `-D clippy::needless-borrow` implied by `-D warnings` error: the borrowed expression implements the required traits --> tests/std.rs:35:38 | 35 | Command::new("cmd").args(&["/C", "exit 1"]).spawn() | ^^^^^^^^^^^^^^^^^ help: change this to: `["/C", "exit 1"]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow error: the borrowed expression implements the required traits --> tests/std.rs:87:22 | 87 | cmd.args(&["/C", "echo foobar"]).stdout(Stdio::piped()); | ^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `["/C", "echo foobar"]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow error: the borrowed expression implements the required traits --> tests/std.rs:145:23 | 145 | .args(&["/C", "exit 1"]) | ^^^^^^^^^^^^^^^^^ help: change this to: `["/C", "exit 1"]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow error: the borrowed expression implements the required traits --> tests/std.rs:156:23 | 156 | .args(&["/C", "exit 0"]) | ^^^^^^^^^^^^^^^^^ help: change this to: `["/C", "exit 0"]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow error: the borrowed expression implements the required traits --> tests/std.rs:189:23 | 189 | .args(&["/C", "echo hello"]) | ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `["/C", "echo hello"]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow error: the borrowed expression implements the required traits --> tests/std.rs:213:23 | 213 | .args(&["/C", "mkdir ."]) | ^^^^^^^^^^^^^^^^^^ help: change this to: `["/C", "mkdir ."]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow error: the borrowed expression implements the required traits --> tests/std.rs:231:38 | 231 | Command::new("cmd").args(&["/C", "exit 1"]).spawn().unwrap() | ^^^^^^^^^^^^^^^^^ help: change this to: `["/C", "exit 1"]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow error: the borrowed expression implements the required traits --> tests/std.rs:243:38 | 243 | Command::new("cmd").args(&["/C", "exit 1"]).spawn().unwrap() | ^^^^^^^^^^^^^^^^^ help: change this to: `["/C", "exit 1"]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow error: the borrowed expression implements the required traits --> tests/std.rs:257:23 | 257 | .args(&["/C", "echo hello"]) | ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `["/C", "echo hello"]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow ``` --- src/lib.rs | 2 +- tests/std.rs | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 220b328..6a6d318 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -207,7 +207,7 @@ impl Child { // Make sure the signal handler is registered before interacting with the process. SIGNALS.get_or_init_blocking(|| Mutex::new( - signal_hook::iterator::Signals::new(&[signal_hook::consts::SIGCHLD]) + signal_hook::iterator::Signals::new([signal_hook::consts::SIGCHLD]) .expect("cannot set signal handler for SIGCHLD"), )); diff --git a/tests/std.rs b/tests/std.rs index 1c57f1d..91c794e 100644 --- a/tests/std.rs +++ b/tests/std.rs @@ -11,7 +11,7 @@ use futures_lite::{future, prelude::*}; fn smoke() { future::block_on(async { let p = if cfg!(target_os = "windows") { - Command::new("cmd").args(&["/C", "exit 0"]).spawn() + Command::new("cmd").args(["/C", "exit 0"]).spawn() } else { Command::new("true").spawn() }; @@ -32,7 +32,7 @@ fn smoke_failure() { fn exit_reported_right() { future::block_on(async { let p = if cfg!(target_os = "windows") { - Command::new("cmd").args(&["/C", "exit 1"]).spawn() + Command::new("cmd").args(["/C", "exit 1"]).spawn() } else { Command::new("false").spawn() }; @@ -84,7 +84,7 @@ fn stdout_works() { future::block_on(async { if cfg!(target_os = "windows") { let mut cmd = Command::new("cmd"); - cmd.args(&["/C", "echo foobar"]).stdout(Stdio::piped()); + cmd.args(["/C", "echo foobar"]).stdout(Stdio::piped()); assert_eq!(run_output(cmd).await, "foobar\r\n"); } else { let mut cmd = Command::new("echo"); @@ -142,7 +142,7 @@ fn test_process_status() { future::block_on(async { let mut status = if cfg!(target_os = "windows") { Command::new("cmd") - .args(&["/C", "exit 1"]) + .args(["/C", "exit 1"]) .status() .await .unwrap() @@ -153,7 +153,7 @@ fn test_process_status() { status = if cfg!(target_os = "windows") { Command::new("cmd") - .args(&["/C", "exit 0"]) + .args(["/C", "exit 0"]) .status() .await .unwrap() @@ -186,7 +186,7 @@ fn test_process_output_output() { stderr, } = if cfg!(target_os = "windows") { Command::new("cmd") - .args(&["/C", "echo hello"]) + .args(["/C", "echo hello"]) .output() .await .unwrap() @@ -210,7 +210,7 @@ fn test_process_output_error() { stderr, } = if cfg!(target_os = "windows") { Command::new("cmd") - .args(&["/C", "mkdir ."]) + .args(["/C", "mkdir ."]) .output() .await .unwrap() @@ -228,7 +228,7 @@ fn test_process_output_error() { fn test_finish_once() { future::block_on(async { let mut prog = if cfg!(target_os = "windows") { - Command::new("cmd").args(&["/C", "exit 1"]).spawn().unwrap() + Command::new("cmd").args(["/C", "exit 1"]).spawn().unwrap() } else { Command::new("false").spawn().unwrap() }; @@ -240,7 +240,7 @@ fn test_finish_once() { fn test_finish_twice() { future::block_on(async { let mut prog = if cfg!(target_os = "windows") { - Command::new("cmd").args(&["/C", "exit 1"]).spawn().unwrap() + Command::new("cmd").args(["/C", "exit 1"]).spawn().unwrap() } else { Command::new("false").spawn().unwrap() }; @@ -254,7 +254,7 @@ fn test_wait_with_output_once() { future::block_on(async { let prog = if cfg!(target_os = "windows") { Command::new("cmd") - .args(&["/C", "echo hello"]) + .args(["/C", "echo hello"]) .stdout(Stdio::piped()) .spawn() .unwrap()