From 612e51058caba2f128b58742e454fb8e664b2335 Mon Sep 17 00:00:00 2001 From: John Nunley Date: Sun, 11 Jun 2023 07:06:39 -0700 Subject: [PATCH 1/2] Bump MSRV to 1.63 --- .github/workflows/ci.yml | 4 ++-- Cargo.toml | 5 +---- build.rs | 17 ----------------- src/lib.rs | 7 ++----- src/pipe.rs | 6 +----- src/signalfd.rs | 7 +------ 6 files changed, 7 insertions(+), 39 deletions(-) delete mode 100644 build.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 016cce8..879c56f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: run: cargo check -Z features=dev_dep - run: cargo test - name: Force tests with pipe implementation - if : startsWith(matrix.os, 'ubuntu-latest') + if: startsWith(matrix.os, 'ubuntu-latest') run: cargo test env: RUSTFLAGS: --cfg async_signal_force_pipe_impl @@ -42,7 +42,7 @@ jobs: os: [ubuntu-latest, windows-latest] # When updating this, the reminder to update the minimum supported # Rust version in Cargo.toml and .clippy.toml. - rust: ['1.48'] + rust: ['1.63'] steps: - uses: actions/checkout@v3 - name: Install Rust diff --git a/Cargo.toml b/Cargo.toml index dbc2865..a8079ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "async-signal" version = "0.2.0" edition = "2018" authors = ["John Nunley "] -rust-version = "1.48" +rust-version = "1.63" description = "Async signal handling" license = "Apache-2.0 OR MIT" repository = "https://github.com/smol-rs/async-signal" @@ -34,6 +34,3 @@ concurrent-queue = "2.2.0" async-io = "1.12.0" futures-lite = "1.12.0" signal-hook = "0.3.14" - -[build-dependencies] -autocfg = "1.1.0" diff --git a/build.rs b/build.rs deleted file mode 100644 index fe1a662..0000000 --- a/build.rs +++ /dev/null @@ -1,17 +0,0 @@ -/// The build constants emitted here are NOT public API. -fn main() { - let cfg = match autocfg::AutoCfg::new() { - Ok(cfg) => cfg, - Err(e) => { - println!( - "cargo:warning=async-signal: failed to detect compiler features: {}", - e - ); - return; - } - }; - - if !cfg.probe_rustc_version(1, 63) { - autocfg::emit("async_signal_no_io_safety"); - } -} diff --git a/src/lib.rs b/src/lib.rs index b64cafd..76ae2cf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,10 +94,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; #[cfg(unix)] -use std::os::unix::io::{AsRawFd, RawFd}; - -#[cfg(all(unix, not(async_signal_no_io_safety)))] -use std::os::unix::io::{AsFd, BorrowedFd}; +use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd}; #[cfg(windows)] mod libc { @@ -380,7 +377,7 @@ impl AsRawFd for Signals { } } -#[cfg(all(unix, not(async_signal_no_io_safety)))] +#[cfg(unix)] impl AsFd for Signals { fn as_fd(&self) -> BorrowedFd<'_> { self.notifier.as_fd() diff --git a/src/pipe.rs b/src/pipe.rs index c879b84..bf3b2b9 100644 --- a/src/pipe.rs +++ b/src/pipe.rs @@ -7,14 +7,11 @@ use futures_io::AsyncRead; use std::io::{self, prelude::*}; use std::mem; -use std::os::unix::io::{AsRawFd, RawFd}; +use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd}; use std::os::unix::net::UnixStream; use std::pin::Pin; use std::task::{Context, Poll}; -#[cfg(not(async_signal_no_io_safety))] -use std::os::unix::io::{AsFd, BorrowedFd}; - const BUFFER_LEN: usize = mem::size_of::(); /// The notifier that uses an asynchronous pipe. @@ -101,7 +98,6 @@ impl AsRawFd for Notifier { } } -#[cfg(not(async_signal_no_io_safety))] impl AsFd for Notifier { fn as_fd(&self) -> BorrowedFd<'_> { self.read.as_fd() diff --git a/src/signalfd.rs b/src/signalfd.rs index e596df2..c3d065a 100644 --- a/src/signalfd.rs +++ b/src/signalfd.rs @@ -18,13 +18,10 @@ use concurrent_queue::ConcurrentQueue; use std::fmt; use std::io; use std::mem; -use std::os::unix::io::{AsRawFd, RawFd}; +use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd}; use std::sync::Arc; use std::task::{Context, Poll}; -#[cfg(not(async_signal_no_io_safety))] -use std::os::unix::io::{AsFd, BorrowedFd}; - const MAX_SIGNALS: usize = 16; /// The notifier that uses Linux's signalfd API. @@ -140,7 +137,6 @@ impl AsRawFd for Notifier { } } -#[cfg(not(async_signal_no_io_safety))] impl AsFd for Notifier { fn as_fd(&self) -> BorrowedFd<'_> { self.fd.as_fd() @@ -197,7 +193,6 @@ impl AsRawFd for Signalfd { } } -#[cfg(not(async_signal_no_io_safety))] impl AsFd for Signalfd { fn as_fd(&self) -> BorrowedFd<'_> { unsafe { BorrowedFd::borrow_raw(self.0) } From 7e6fca50d50af958b0eb4fa7844d7e6dd9f68956 Mon Sep 17 00:00:00 2001 From: John Nunley Date: Sun, 11 Jun 2023 07:12:59 -0700 Subject: [PATCH 2/2] Satiate clippy --- examples/print.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/print.rs b/examples/print.rs index 1839489..2ef250c 100644 --- a/examples/print.rs +++ b/examples/print.rs @@ -8,7 +8,7 @@ fn main() -> Result<(), Box> { async_io::block_on(async { // Register the signals we want to receive. #[cfg(unix)] - let signals = Signals::new(&[ + let signals = Signals::new([ Signal::Term, Signal::Quit, Signal::Int, @@ -20,7 +20,7 @@ fn main() -> Result<(), Box> { ])?; #[cfg(windows)] - let signals = Signals::new(&[Signal::Int])?; + let signals = Signals::new([Signal::Int])?; // Loop over the signals. signals