diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 39c90b7..ed54d2f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,7 @@ jobs: os: [ubuntu-latest, windows-latest] # When updating this, the reminder to update the minimum supported # Rust version in Cargo.toml. - rust: ['1.48'] + rust: ['1.63'] steps: - uses: actions/checkout@v3 - name: Install Rust diff --git a/Cargo.toml b/Cargo.toml index fd05bff..1da6bf1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ name = "async-process" version = "1.7.0" authors = ["Stjepan Glavina "] edition = "2018" -rust-version = "1.48" +rust-version = "1.63" description = "Async interface for working with processes" license = "Apache-2.0 OR MIT" repository = "https://github.com/smol-rs/async-process" @@ -20,9 +20,6 @@ cfg-if = "1.0" event-listener = "2.4.0" futures-lite = "1.11.0" -[build-dependencies] -autocfg = "1" - [target.'cfg(unix)'.dependencies] async-io = "1.8" rustix = { version = "0.37", default-features = false, features = ["std", "fs"] } diff --git a/build.rs b/build.rs deleted file mode 100644 index 6752846..0000000 --- a/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -fn main() { - let cfg = match autocfg::AutoCfg::new() { - Ok(cfg) => cfg, - Err(e) => { - println!( - "cargo:warning=async-process: failed to detect compiler features: {}", - e - ); - return; - } - }; - - if !cfg.probe_rustc_version(1, 62) { - autocfg::emit("async_process_no_windows_raw_arg"); - } - if !cfg.probe_rustc_version(1, 63) { - autocfg::emit("async_process_no_io_safety"); - } -} diff --git a/src/lib.rs b/src/lib.rs index 0b7e59e..6a6d318 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -60,12 +60,10 @@ use std::thread; #[cfg(unix)] use async_io::Async; -#[cfg(all(not(async_process_no_io_safety), unix))] +#[cfg(unix)] use std::convert::{TryFrom, TryInto}; -#[cfg(all(not(async_process_no_io_safety), unix))] -use std::os::unix::io::{AsFd, BorrowedFd, OwnedFd}; #[cfg(unix)] -use std::os::unix::io::{AsRawFd, RawFd}; +use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd}; #[cfg(windows)] use blocking::Unblock; @@ -209,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"), )); @@ -519,16 +517,14 @@ impl AsRawFd for ChildStdin { } } -/// **Note:** This implementation is only available on Rust 1.63+. -#[cfg(all(not(async_process_no_io_safety), unix))] +#[cfg(unix)] impl AsFd for ChildStdin { fn as_fd(&self) -> BorrowedFd<'_> { self.0.as_fd() } } -/// **Note:** This implementation is only available on Rust 1.63+. -#[cfg(all(not(async_process_no_io_safety), unix))] +#[cfg(unix)] impl TryFrom for OwnedFd { type Error = io::Error; @@ -605,16 +601,14 @@ impl AsRawFd for ChildStdout { } } -/// **Note:** This implementation is only available on Rust 1.63+. -#[cfg(all(not(async_process_no_io_safety), unix))] +#[cfg(unix)] impl AsFd for ChildStdout { fn as_fd(&self) -> BorrowedFd<'_> { self.0.as_fd() } } -/// **Note:** This implementation is only available on Rust 1.63+. -#[cfg(all(not(async_process_no_io_safety), unix))] +#[cfg(unix)] impl TryFrom for OwnedFd { type Error = io::Error; @@ -680,16 +674,14 @@ impl AsRawFd for ChildStderr { } } -/// **Note:** This implementation is only available on Rust 1.63+. -#[cfg(all(not(async_process_no_io_safety), unix))] +#[cfg(unix)] impl AsFd for ChildStderr { fn as_fd(&self) -> BorrowedFd<'_> { self.0.as_fd() } } -/// **Note:** This implementation is only available on Rust 1.63+. -#[cfg(all(not(async_process_no_io_safety), unix))] +#[cfg(unix)] impl TryFrom for OwnedFd { type Error = io::Error; diff --git a/src/windows.rs b/src/windows.rs index 453d3a5..020a290 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -1,6 +1,5 @@ //! Windows-specific extensions. -#[cfg(not(async_process_no_windows_raw_arg))] use std::ffi::OsStr; use std::os::windows::io::{AsRawHandle, RawHandle}; use std::os::windows::process::CommandExt as _; @@ -23,9 +22,6 @@ pub trait CommandExt: crate::sealed::Sealed { /// /// This is useful for passing arguments to `cmd.exe /c`, which doesn't follow /// `CommandLineToArgvW` escaping rules. - /// - /// **Note:** This method is only available on Rust 1.62+. - #[cfg(not(async_process_no_windows_raw_arg))] fn raw_arg>(&mut self, text_to_append_as_is: S) -> &mut Command; } @@ -36,7 +32,6 @@ impl CommandExt for Command { self } - #[cfg(not(async_process_no_windows_raw_arg))] fn raw_arg>(&mut self, text_to_append_as_is: S) -> &mut Command { self.inner.raw_arg(text_to_append_as_is); self 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()