From 79c89d779da9ebcd9d098d623e26c5c7e9d72220 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Tue, 20 Aug 2024 19:43:54 +0200 Subject: [PATCH 01/10] deps: update gloo-timers to 0.3 --- Cargo.toml | 2 +- src/stream/mod.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 094dae161..34ae7add5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,7 +86,7 @@ futures-lite = { version = "2.0.0", optional = true } async-process = { version = "2.0.0", optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] -gloo-timers = { version = "0.2.1", features = ["futures"], optional = true } +gloo-timers = { version = "0.3.0", features = ["futures"], optional = true } wasm-bindgen-futures = { version = "0.4.10", optional = true } futures-channel = { version = "0.3.4", optional = true } diff --git a/src/stream/mod.rs b/src/stream/mod.rs index f7f2727a1..504face8b 100644 --- a/src/stream/mod.rs +++ b/src/stream/mod.rs @@ -40,6 +40,10 @@ //! type Item; //! fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll>; //! } +//! # impl Stream for () { +//! # type Item = (); +//! # fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { Poll::Pending } +//! # } //! ``` //! //! A stream has a method, [`next`], which when called, returns an From 57eafb41d085d9b9f771f67889e890b80670fe54 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Tue, 20 Aug 2024 22:23:57 +0200 Subject: [PATCH 02/10] silence warnings reported by newer rust versions --- examples/a-chat/server.rs | 1 + src/future/future/mod.rs | 2 ++ src/io/buf_writer.rs | 2 +- src/io/read/bytes.rs | 2 +- src/io/read/chain.rs | 2 +- src/io/stderr.rs | 6 ++++-- src/io/stdin.rs | 10 ++++++---- src/io/stdout.rs | 6 ++++-- src/lib.rs | 2 -- src/net/tcp/stream.rs | 4 ++-- src/net/udp/mod.rs | 2 +- src/stream/mod.rs | 3 ++- src/utils.rs | 7 ++----- 13 files changed, 27 insertions(+), 22 deletions(-) diff --git a/examples/a-chat/server.rs b/examples/a-chat/server.rs index e049a490e..d3ac74699 100644 --- a/examples/a-chat/server.rs +++ b/examples/a-chat/server.rs @@ -96,6 +96,7 @@ async fn connection_writer_loop( None => break, }, void = shutdown.next().fuse() => match void { + #[allow(unreachable_patterns)] Some(void) => match void {}, None => break, } diff --git a/src/future/future/mod.rs b/src/future/future/mod.rs index 47187b235..9a8bfcc1f 100644 --- a/src/future/future/mod.rs +++ b/src/future/future/mod.rs @@ -27,6 +27,7 @@ pub use core::future::Future as Future; [`Future`]: ../future/trait.Future.html "#] +#[cfg(any(feature = "std", feature = "docs"))] pub trait FutureExt: Future { /// Returns a Future that delays execution for a specified time. /// @@ -284,5 +285,6 @@ pub trait FutureExt: Future { } } +#[cfg(any(feature = "std", feature = "docs"))] impl FutureExt for T {} diff --git a/src/io/buf_writer.rs b/src/io/buf_writer.rs index c972937fd..230954e88 100644 --- a/src/io/buf_writer.rs +++ b/src/io/buf_writer.rs @@ -114,7 +114,7 @@ pin_project! { /// # Ok(()) }) } ///``` #[derive(Debug)] -pub struct IntoInnerError(W, crate::io::Error); +pub struct IntoInnerError(W, #[allow(dead_code)] crate::io::Error); impl BufWriter { /// Creates a new `BufWriter` with a default buffer capacity. The default is currently 8 KB, diff --git a/src/io/read/bytes.rs b/src/io/read/bytes.rs index ab9259611..786fdaa57 100644 --- a/src/io/read/bytes.rs +++ b/src/io/read/bytes.rs @@ -32,7 +32,7 @@ impl Stream for Bytes { } } -#[cfg(all(test, default))] +#[cfg(all(test, feature = "default", not(target_arch = "wasm32")))] mod tests { use crate::io; use crate::prelude::*; diff --git a/src/io/read/chain.rs b/src/io/read/chain.rs index 4fcdb0ec9..b5eac5814 100644 --- a/src/io/read/chain.rs +++ b/src/io/read/chain.rs @@ -165,7 +165,7 @@ impl BufRead for Chain { } } -#[cfg(all(test, default))] +#[cfg(all(test, feature = "default", not(target_arch = "wasm32")))] mod tests { use crate::io; use crate::prelude::*; diff --git a/src/io/stderr.rs b/src/io/stderr.rs index ca8d23d5f..81cc197b9 100644 --- a/src/io/stderr.rs +++ b/src/io/stderr.rs @@ -204,11 +204,13 @@ cfg_windows! { } cfg_io_safety! { - use crate::os::unix::io::{AsHandle, BorrowedHandle}; + use crate::os::windows::io::{AsHandle, BorrowedHandle}; impl AsHandle for Stderr { fn as_handle(&self) -> BorrowedHandle<'_> { - std::io::stderr().as_handle() + unsafe { + BorrowedHandle::borrow_raw(std::io::stderr().as_raw_handle()) + } } } } diff --git a/src/io/stdin.rs b/src/io/stdin.rs index b994bcd07..d8f96d49e 100644 --- a/src/io/stdin.rs +++ b/src/io/stdin.rs @@ -230,11 +230,13 @@ cfg_windows! { } cfg_io_safety! { - use crate::os::unix::io::{AsFd, BorrowedFd}; + use crate::os::windows::io::{AsHandle, BorrowedHandle}; - impl AsFd for Stdin { - fn as_fd(&self) -> BorrowedFd<'_> { - std::io::stdin().as_fd() + impl AsHandle for Stdin { + fn as_handle(&self) -> BorrowedHandle<'_> { + unsafe { + BorrowedHandle::borrow_raw(std::io::stdin().as_raw_handle()) + } } } } diff --git a/src/io/stdout.rs b/src/io/stdout.rs index 2444bbd7d..3cc570dc8 100644 --- a/src/io/stdout.rs +++ b/src/io/stdout.rs @@ -204,11 +204,13 @@ cfg_windows! { } cfg_io_safety! { - use crate::os::unix::io::{AsHandle, BorrowedHandle}; + use crate::os::windows::io::{AsHandle, BorrowedHandle}; impl AsHandle for Stdout { fn as_handle(&self) -> BorrowedHandle<'_> { - std::io::stdout().as_handle() + unsafe { + BorrowedHandle::borrow_raw(std::io::stdout().as_raw_handle()) + } } } } diff --git a/src/lib.rs b/src/lib.rs index 86786e814..48eaa0693 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -284,8 +284,6 @@ #![doc(test(attr(allow(unused_extern_crates, unused_variables))))] #![doc(html_logo_url = "https://async.rs/images/logo--hero.svg")] -extern crate alloc; - #[macro_use] mod utils; diff --git a/src/net/tcp/stream.rs b/src/net/tcp/stream.rs index a6cbc927c..3311f904c 100644 --- a/src/net/tcp/stream.rs +++ b/src/net/tcp/stream.rs @@ -477,13 +477,13 @@ cfg_windows! { impl From for TcpStream { fn from(fd: OwnedSocket) -> TcpStream { - std::net::TcpListener::from(fd).into() + std::net::TcpStream::from(fd).into() } } impl From for OwnedSocket { fn from(stream: TcpStream) -> OwnedSocket { - stream.watcher.into_inner().unwrap().into() + stream.watcher.get_ref().try_clone().unwrap().into() } } } diff --git a/src/net/udp/mod.rs b/src/net/udp/mod.rs index 7c8798f5c..3bb2c6e9c 100644 --- a/src/net/udp/mod.rs +++ b/src/net/udp/mod.rs @@ -620,7 +620,7 @@ cfg_windows! { impl From for UdpSocket { fn from(fd: OwnedSocket) -> UdpSocket { - std::net::TcpListener::from(fd).into() + std::net::UdpSocket::from(fd).into() } } diff --git a/src/stream/mod.rs b/src/stream/mod.rs index 504face8b..8dd7d6339 100644 --- a/src/stream/mod.rs +++ b/src/stream/mod.rs @@ -34,9 +34,10 @@ //! [`Stream`] looks like this: //! //! ``` +//! #![allow(dead_code)] //! # use async_std::task::{Context, Poll}; //! # use std::pin::Pin; -//! trait Stream { +//! pub trait Stream { //! type Item; //! fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll>; //! } diff --git a/src/utils.rs b/src/utils.rs index 853ace0e9..d1cb063bd 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,5 +1,3 @@ -use alloc::string::String; - /// Calls a function and aborts if it panics. /// /// This is useful in unsafe code where we can't recover from panics. @@ -55,6 +53,7 @@ pub fn random(n: u32) -> u32 { } /// Add additional context to errors +#[cfg(feature = "std")] pub(crate) trait Context { fn context(self, message: impl Fn() -> String) -> Self; } @@ -148,7 +147,7 @@ macro_rules! cfg_unstable_default { ($($item:item)*) => { $( #[cfg(all(feature = "default", feature = "unstable"))] - #[cfg_attr(feature = "docs", doc(unstable))] + #[cfg_attr(feature = "docs", doc(cfg(unstable)))] $item )* } @@ -161,7 +160,6 @@ macro_rules! cfg_unix { ($($item:item)*) => { $( #[cfg(any(unix, feature = "docs"))] - #[cfg_attr(feature = "docs", doc(cfg(unix)))] $item )* } @@ -174,7 +172,6 @@ macro_rules! cfg_windows { ($($item:item)*) => { $( #[cfg(any(windows, feature = "docs"))] - #[cfg_attr(feature = "docs", doc(cfg(windows)))] $item )* } From 566684c240bf3d5bfd4df9290791d30104e9bed8 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Tue, 20 Aug 2024 22:14:17 +0200 Subject: [PATCH 03/10] CHANGELOG.md: updates for 1.13.0 --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4130cc021..79b290bf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ All notable changes to async-std will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://book.async.rs/overview/stability-guarantees.html). +# [1.13.0] - 2024-09-06 + +## Added +- IO Safety traits implementations + +## Changed +- Various dependencies updates +- Export `BufReadExt` and `SeekExt` from `async_std::io` + # [1.12.0] - 2022-06-18 ## Added From 0c382dbf370544d9173ceadd38c93bad09b1f984 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Tue, 20 Aug 2024 22:15:14 +0200 Subject: [PATCH 04/10] Bump version to 1.13.0 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 34ae7add5..e074a30d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-std" -version = "1.12.0" +version = "1.13.0" authors = [ "Stjepan Glavina ", "Yoshua Wuyts ", From 355ce2660592f077847f3d99fc27d582e67a36e0 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sun, 8 Sep 2024 08:55:46 +0800 Subject: [PATCH 05/10] docs: Minor fixes to CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79b290bf1..e314ffbce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://book.async.rs/overview # [1.12.0] - 2022-06-18 ## Added -- `std::task::spawn_blocking` is now stabilized. We consider it a fundamental API for bridging between blocking code and async code, and we widely use it within async-std's own implementation. +- `async_std::task::spawn_blocking` is now stabilized. We consider it a fundamental API for bridging between blocking code and async code, and we widely use it within async-std's own implementation. - Add `TryFrom` implementations to convert `TcpListener`, `TcpStream`, `UdpSocket`, `UnixDatagram`, `UnixListener`, and `UnixStream` to their synchronous equivalents, including putting them back into blocking mode. ## Changed @@ -307,7 +307,7 @@ Including improved performance, stability, and the addition of various - Fixed documentation for `UdpSocket::send` ([#671](https://github.com/async-rs/async-std/pull/671)) - Fixed typo in stream documentation ([#650](https://github.com/async-rs/async-std/pull/650)) - Fixed typo on `sync::JoinHandle` documentation ([#659](https://github.com/async-rs/async-std/pull/659)) -- Removed use of `std::error::Error::description` which failed CI ([#661](https://github.com/async-rs/async-std/pull/662)) +- Removed use of `std::error::Error::description` which failed CI ([#661](https://github.com/async-rs/async-std/pull/661)) - Removed the use of rustfmt's unstable `format_code_in_doc_comments` option which failed CI ([#685](https://github.com/async-rs/async-std/pull/685)) - Fixed a code typo in the `task::sleep` example ([#688](https://github.com/async-rs/async-std/pull/688)) From dba67cd14eb5bc70f15c5846633f46828daee902 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sun, 8 Sep 2024 09:38:19 +0800 Subject: [PATCH 06/10] Add rust-version 1.63 --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index e074a30d2..85237a2cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ authors = [ "Contributors to async-std", ] edition = "2018" +rust-version = "1.63" license = "Apache-2.0 OR MIT" repository = "https://github.com/async-rs/async-std" homepage = "https://async.rs" From 6fd127808d2db180d588a4e54302a09c9b3101ce Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sun, 8 Sep 2024 10:04:38 +0800 Subject: [PATCH 07/10] chore: Fix rustdoc lints --- src/lib.rs | 5 +++-- src/sync/mod.rs | 4 ++-- src/task/block_on.rs | 8 +++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 48eaa0693..21f5f8acc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(rustdoc::invalid_html_tags)] //! # Async version of the Rust standard library //! //! `async-std` is a foundation of portable Rust software, a set of minimal and battle-tested @@ -191,7 +192,7 @@ //! unstable +//! > unstable //! are available only when the `unstable` Cargo feature is enabled: //! //! ```toml @@ -204,7 +205,7 @@ //! attributes +//! > attributes //! are available only when the `attributes` Cargo feature is enabled: //! //! ```toml diff --git a/src/sync/mod.rs b/src/sync/mod.rs index 35203a6ea..1d8579614 100644 --- a/src/sync/mod.rs +++ b/src/sync/mod.rs @@ -95,9 +95,9 @@ //! at the same time: In multi-threaded scenarios, you can use two //! kinds of primitives to deal with synchronization: //! - [memory fences] to ensure memory accesses are made visible to -//! other CPUs in the right order. +//! other CPUs in the right order. //! - [atomic operations] to ensure simultaneous access to the same -//! memory location doesn't lead to undefined behavior. +//! memory location doesn't lead to undefined behavior. //! //! [prefetching]: https://en.wikipedia.org/wiki/Cache_prefetching //! [compiler fences]: https://doc.rust-lang.org/std/sync/atomic/fn.compiler_fence.html diff --git a/src/task/block_on.rs b/src/task/block_on.rs index fa66f915b..3ab4dc06f 100644 --- a/src/task/block_on.rs +++ b/src/task/block_on.rs @@ -19,11 +19,9 @@ use crate::task::Builder; /// ```no_run /// use async_std::task; /// -/// fn main() { -/// task::block_on(async { -/// println!("Hello, world!"); -/// }) -/// } +/// task::block_on(async { +/// println!("Hello, world!"); +/// }) /// ``` #[cfg(not(target_os = "unknown"))] pub fn block_on(future: F) -> T From 7b3839bf21d63fc0402f8716fa93f6ea5d796b0e Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Wed, 11 Sep 2024 06:51:22 +0800 Subject: [PATCH 08/10] Add MSRV 1.63 to CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca775eac8..a3eb933dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] - rust: [nightly, beta, stable] + rust: [nightly, beta, stable, 1.63] steps: - uses: actions/checkout@v3 From 5e74d1b88da2233c6f4d443804eb27545c74164b Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sat, 1 Mar 2025 21:20:14 +0000 Subject: [PATCH 09/10] Remove `deny(warnings)` which is causing CI to fail --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 21f5f8acc..b807d448d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -281,7 +281,7 @@ #![cfg_attr(feature = "docs", feature(doc_cfg))] #![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)] #![allow(clippy::mutex_atomic, clippy::module_inception)] -#![doc(test(attr(deny(rust_2018_idioms, warnings))))] +#![doc(test(attr(deny(rust_2018_idioms))))] #![doc(test(attr(allow(unused_extern_crates, unused_variables))))] #![doc(html_logo_url = "https://async.rs/images/logo--hero.svg")] From fb56bffdbb4699e1add70a0f834dee6f57c398eb Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Fri, 21 Feb 2025 21:37:15 +0100 Subject: [PATCH 10/10] Officially sunset async-std --- CHANGELOG.md | 6 ++++ Cargo.toml | 4 +-- README.md | 88 +++++++++------------------------------------------- 3 files changed, 22 insertions(+), 76 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e314ffbce..ebb3ffd80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to async-std will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://book.async.rs/overview/stability-guarantees.html). +# [1.13.1] - 2025-02-21 + +`async-std` has officially been discontinued. We recommend that all users and +libraries migrate to the excellent [`smol`](https://github.com/smol-rs/smol/) +project. + # [1.13.0] - 2024-09-06 ## Added diff --git a/Cargo.toml b/Cargo.toml index 85237a2cd..fed440172 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-std" -version = "1.13.0" +version = "1.13.1" authors = [ "Stjepan Glavina ", "Yoshua Wuyts ", @@ -12,7 +12,7 @@ rust-version = "1.63" license = "Apache-2.0 OR MIT" repository = "https://github.com/async-rs/async-std" homepage = "https://async.rs" -description = "Async version of the Rust standard library" +description = "Deprecated in favor of `smol` - Async version of the Rust standard library" keywords = ["async", "await", "future", "std", "task"] categories = ["asynchronous", "concurrency", "network-programming"] diff --git a/README.md b/README.md index 9d25315dc..f432898dc 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,19 @@ -

async-std

-
- - Async version of the Rust standard library - -
+# `async-std` has been discontinued; use `smol` instead -
+We created `async-std` to demonstrate the value of making a library as close to +`std` as possible, but async. We think that demonstration was successful, and +we hope it will influence future design and development directions of async in +`std`. However, in the meantime, the [`smol`](https://github.com/smol-rs/smol/) +project came about and provided a great executor and libraries for asynchronous +use in the Rust ecosystem. We think that resources would be better spent +consolidating around `smol`, rather than continuing to provide occasional +maintenance of `async-std`. As such, we recommend that all users of +`async-std`, and all libraries built on `async-std`, switch to `smol` instead. + +In addition to the `smol` project as a direct replacement, you may find other +parts of the futures ecosystem useful, including `futures-concurrency`, +`async-io`, `futures-lite`, and `async-compat`. -
- - - CI Status - - - - Crates.io version - - - - Download - - - - docs.rs docs - - - - chat - -

@@ -44,14 +24,6 @@ Book - | - - Releases - - | - - Contributing -

@@ -111,38 +83,6 @@ creation, with an adaptive lock-free executor, threadpool and network driver to create a smooth system that processes work at a high pace with low latency, using Rust's familiar stdlib API. -## Installation - -Run this in your projects folder: - -```sh -$ cargo add async-std -``` - -We also provide a set of "unstable" features with async-std. See the [features -documentation] on how to enable them. - -[cargo add]: https://doc.rust-lang.org/cargo/commands/cargo-add.html -[features documentation]: https://docs.rs/async-std/#features - -## Ecosystem - - * [async-tls](https://crates.io/crates/async-tls) — Async TLS/SSL streams using **Rustls**. - - * [async-native-tls](https://crates.io/crates/async-native-tls) — **Native TLS** for Async. Native TLS for futures and async-std. - - * [async-tungstenite](https://crates.io/crates/async-tungstenite) — Asynchronous **WebSockets** for async-std, tokio, gio and any std Futures runtime. - - * [Tide](https://crates.io/crates/tide) — Serve the web. A modular **web framework** built around async/await. - - * [SQLx](https://crates.io/crates/sqlx) — The Rust **SQL** Toolkit. SQLx is a 100% safe Rust library for Postgres and MySQL with compile-time checked queries. - - * [Surf](https://crates.io/crates/surf) — Surf the web. Surf is a friendly **HTTP client** built for casual Rustaceans and veterans alike. - - * [Xactor](https://crates.io/crates/xactor) — Xactor is a rust actors framework based on async-std. - - * [async-graphql](https://crates.io/crates/async-graphql) — A GraphQL server library implemented in rust, with full support for async/await. - ## License