Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump MSRV to 1.63 #45

Merged
merged 2 commits into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name = "async-process"
version = "1.7.0"
authors = ["Stjepan Glavina <[email protected]>"]
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"
Expand All @@ -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"] }
Expand Down
19 changes: 0 additions & 19 deletions build.rs

This file was deleted.

26 changes: 9 additions & 17 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"),
));

Expand Down Expand Up @@ -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<ChildStdin> for OwnedFd {
type Error = io::Error;

Expand Down Expand Up @@ -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<ChildStdout> for OwnedFd {
type Error = io::Error;

Expand Down Expand Up @@ -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<ChildStderr> for OwnedFd {
type Error = io::Error;

Expand Down
5 changes: 0 additions & 5 deletions src/windows.rs
Original file line number Diff line number Diff line change
@@ -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 _;
Expand All @@ -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<S: AsRef<OsStr>>(&mut self, text_to_append_as_is: S) -> &mut Command;
}

Expand All @@ -36,7 +32,6 @@ impl CommandExt for Command {
self
}

#[cfg(not(async_process_no_windows_raw_arg))]
fn raw_arg<S: AsRef<OsStr>>(&mut self, text_to_append_as_is: S) -> &mut Command {
self.inner.raw_arg(text_to_append_as_is);
self
Expand Down
20 changes: 10 additions & 10 deletions tests/std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};
Expand All @@ -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()
};
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
};
Expand All @@ -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()
};
Expand All @@ -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()
Expand Down