diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e76a8c..3a9daf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,15 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com ## [Unreleased] +- Update to [new coroutine API since nightly-2023-10-21](https://github.com/rust-lang/rust/pull/116958). + + On the user side of this crate, the only changes required are the following: + + ```diff + - #![feature(generators)] + + #![feature(coroutines)] + ``` + ## [0.2.8] - 2023-10-09 - Update to syn 2.0. ([#92](https://github.com/taiki-e/futures-async-stream/pull/92)) diff --git a/README.md b/README.md index b50d7b2..498c5ce 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Async stream for Rust and the futures crate. This crate provides useful features for streams, using `async_await` and -unstable [`generators`](https://github.com/rust-lang/rust/issues/43122). +unstable [`coroutines`](https://github.com/rust-lang/rust/issues/43122). ## Usage @@ -54,14 +54,14 @@ loops can only be used inside of `async` functions, closures, blocks, ## `#[stream]` -Creates streams via generators. +Creates streams via coroutines. This is a reimplement of [futures-await]'s `#[stream]` for futures 0.3 and is an experimental implementation of [the idea listed as the next step of async/await](https://github.com/rust-lang/rfcs/blob/HEAD/text/2394-async_await.md#generators-and-streams). ```rust -#![feature(generators)] +#![feature(coroutines)] use futures::stream::Stream; use futures_async_stream::stream; @@ -86,7 +86,7 @@ via the `yield` expression. `#[stream]` can also be used on async blocks: ```rust -#![feature(generators, proc_macro_hygiene, stmt_expr_attributes)] +#![feature(coroutines, proc_macro_hygiene, stmt_expr_attributes)] use futures::stream::Stream; use futures_async_stream::stream; @@ -110,7 +110,7 @@ You can use async stream functions in traits by passing `boxed` or `boxed_local` as an argument. ```rust -#![feature(generators)] +#![feature(coroutines)] use futures_async_stream::stream; @@ -138,7 +138,7 @@ If you passed `boxed_local` instead of `boxed`, async stream function returns a non-thread-safe stream (`Pin + 'lifetime>>`). ```rust -#![feature(generators)] +#![feature(coroutines)] use std::pin::Pin; @@ -170,7 +170,7 @@ returned stream is `Result` with `Ok` being the value yielded and `Err` the error type returned by `?` operator or `return Err(...)`. ```rust -#![feature(generators)] +#![feature(coroutines)] use futures::stream::Stream; use futures_async_stream::try_stream; diff --git a/futures-async-stream-macro/src/lib.rs b/futures-async-stream-macro/src/lib.rs index 63f498b..a8ad79a 100644 --- a/futures-async-stream-macro/src/lib.rs +++ b/futures-async-stream-macro/src/lib.rs @@ -48,7 +48,7 @@ pub fn for_await(args: TokenStream, input: TokenStream) -> TokenStream { expr.into_token_stream().into() } -/// Creates streams via generators. +/// Creates streams via coroutines. /// /// See crate level documentation for details. #[proc_macro_attribute] @@ -58,7 +58,7 @@ pub fn stream(args: TokenStream, input: TokenStream) -> TokenStream { .into() } -/// Creates streams via generators. This is equivalent to `#[stream]` on async blocks. +/// Creates streams via coroutines. This is equivalent to `#[stream]` on async blocks. #[proc_macro] pub fn stream_block(input: TokenStream) -> TokenStream { let input = TokenStream::from(TokenTree::Group(Group::new(Delimiter::Brace, input))); @@ -68,7 +68,7 @@ pub fn stream_block(input: TokenStream) -> TokenStream { stream::parse_async(&mut expr, parse::Context::Stream).into() } -/// Creates streams via generators. +/// Creates streams via coroutines. /// /// See crate level documentation for details. #[proc_macro_attribute] @@ -78,7 +78,7 @@ pub fn try_stream(args: TokenStream, input: TokenStream) -> TokenStream { .into() } -/// Creates streams via generators. This is equivalent to `#[try_stream]` on async blocks. +/// Creates streams via coroutines. This is equivalent to `#[try_stream]` on async blocks. #[proc_macro] pub fn try_stream_block(input: TokenStream) -> TokenStream { let input = TokenStream::from(TokenTree::Group(Group::new(Delimiter::Brace, input))); diff --git a/futures-async-stream-macro/src/stream.rs b/futures-async-stream-macro/src/stream.rs index 537efdd..51a2ae3 100644 --- a/futures-async-stream-macro/src/stream.rs +++ b/futures-async-stream-macro/src/stream.rs @@ -304,7 +304,7 @@ fn expand_async_body(inputs: Punctuated) -> (Vec, Vec, mut __arg1: ) -> impl Stream { - // from_generator(static move || { + // from_coroutine(static move || { // let ref = __arg1; // // // ... @@ -358,14 +358,14 @@ fn make_gen_body( ) -> TokenStream { let (gen_function, ret_value, ret_ty) = match cx { Context::Stream => ( - quote!(::futures_async_stream::__private::stream::from_generator), + quote!(::futures_async_stream::__private::stream::from_coroutine), TokenStream::new(), quote!(()), ), Context::TryStream => { let error = error.map_or_else(|| quote!(_), ToTokens::to_token_stream); ( - quote!(::futures_async_stream::__private::try_stream::from_generator), + quote!(::futures_async_stream::__private::try_stream::from_coroutine), quote!(::futures_async_stream::__private::Ok(())), quote!(::futures_async_stream::__private::Result<(), #error>), ) @@ -380,7 +380,7 @@ fn make_gen_body( | -> #ret_ty { let (): () = #block; - // Ensure that this closure is a generator, even if it doesn't + // Ensure that this closure is a coroutine, even if it doesn't // have any `yield` statements. #[allow(unreachable_code)] { diff --git a/futures-async-stream-macro/src/visitor.rs b/futures-async-stream-macro/src/visitor.rs index 72f6b2a..583aef6 100644 --- a/futures-async-stream-macro/src/visitor.rs +++ b/futures-async-stream-macro/src/visitor.rs @@ -15,7 +15,7 @@ use crate::{ /// The scope in which `#[for_await]`, `.await`, or `yield` was called. /// -/// The type of generator depends on which scope is called. +/// The type of coroutine depends on which scope is called. #[derive(Clone, Copy, PartialEq)] pub(crate) enum Scope { /// `async fn`, `async {}`, or `async ||` @@ -93,8 +93,8 @@ impl Visitor { let pinned = def_site_ident!("__pinned"); - // It needs to adjust the type yielded by the macro because generators used internally by - // async fn yield `()` type, but generators used internally by `stream` yield + // It needs to adjust the type yielded by the macro because coroutines used internally by + // async fn yield `()` type, but coroutines used internally by `stream` yield // `Poll` type. let match_next = match self.scope { Scope::Future => { @@ -226,8 +226,8 @@ impl Visitor { /// Visits `.await`. /// - /// It needs to adjust the type yielded by the macro because generators used internally by - /// async fn yield `()` type, but generators used internally by `stream` yield + /// It needs to adjust the type yielded by the macro because coroutines used internally by + /// async fn yield `()` type, but coroutines used internally by `stream` yield /// `Poll` type. fn visit_await(&self, expr: &mut Expr) { if !self.scope.is_stream() { diff --git a/src/lib.rs b/src/lib.rs index 9aa38b8..469f6cd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,7 @@ Async stream for Rust and the futures crate. This crate provides useful features for streams, using `async_await` and -unstable [`generators`](https://github.com/rust-lang/rust/issues/43122). +unstable [`coroutines`](https://github.com/rust-lang/rust/issues/43122). ## Usage @@ -49,14 +49,14 @@ loops can only be used inside of `async` functions, closures, blocks, ## `#[stream]` -Creates streams via generators. +Creates streams via coroutines. This is a reimplement of [futures-await]'s `#[stream]` for futures 0.3 and is an experimental implementation of [the idea listed as the next step of async/await](https://github.com/rust-lang/rfcs/blob/HEAD/text/2394-async_await.md#generators-and-streams). ```rust -#![feature(generators)] +#![feature(coroutines)] use futures::stream::Stream; use futures_async_stream::stream; @@ -81,7 +81,7 @@ via the `yield` expression. `#[stream]` can also be used on async blocks: ```rust -#![feature(generators, proc_macro_hygiene, stmt_expr_attributes)] +#![feature(coroutines, proc_macro_hygiene, stmt_expr_attributes)] use futures::stream::Stream; use futures_async_stream::stream; @@ -105,7 +105,7 @@ You can use async stream functions in traits by passing `boxed` or `boxed_local` as an argument. ```rust -#![feature(generators)] +#![feature(coroutines)] use futures_async_stream::stream; @@ -133,7 +133,7 @@ If you passed `boxed_local` instead of `boxed`, async stream function returns a non-thread-safe stream (`Pin + 'lifetime>>`). ```rust -#![feature(generators)] +#![feature(coroutines)] use std::pin::Pin; @@ -165,7 +165,7 @@ returned stream is `Result` with `Ok` being the value yielded and `Err` the error type returned by `?` operator or `return Err(...)`. ```rust -#![feature(generators)] +#![feature(coroutines)] use futures::stream::Stream; use futures_async_stream::try_stream; @@ -295,7 +295,7 @@ where clippy::undocumented_unsafe_blocks, )] #![allow(clippy::must_use_candidate)] -#![feature(generator_trait)] +#![feature(coroutine_trait)] #[cfg(test)] extern crate std; @@ -318,7 +318,7 @@ pub use futures_async_stream_macro::try_stream_block; mod future { use core::{ future::Future, - ops::{Generator, GeneratorState}, + ops::{Coroutine, CoroutineState}, pin::Pin, ptr::NonNull, task::{Context, Poll}, @@ -331,7 +331,7 @@ mod future { /// This type is needed because: /// - /// a) Generators cannot implement `for<'a, 'b> Generator<&'a mut Context<'b>>`, so we need to pass + /// a) Coroutines cannot implement `for<'a, 'b> Coroutine<&'a mut Context<'b>>`, so we need to pass /// a raw pointer (see ). /// b) Raw pointers and `NonNull` aren't `Send` or `Sync`, so that would make every single future /// non-Send/Sync as well, and we don't want that. @@ -349,15 +349,15 @@ mod future { // SAFETY: see `Send` impl unsafe impl Sync for ResumeTy {} - /// Wrap a generator in a future. + /// Wrap a coroutine in a future. /// /// This function returns a `GenFuture` underneath, but hides it in `impl Trait` to give /// better error messages (`impl Future` rather than `GenFuture<[closure.....]>`). #[doc(hidden)] #[inline] - pub fn from_generator(gen: G) -> impl Future + pub fn from_coroutine(gen: G) -> impl Future where - G: Generator, + G: Coroutine, { GenFuture(gen) } @@ -367,18 +367,18 @@ mod future { impl Future for GenFuture where - G: Generator, + G: Coroutine, { type Output = G::Return; #[inline] fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); - // Resume the generator, turning the `&mut Context` into a `NonNull` raw pointer. The + // Resume the coroutine, turning the `&mut Context` into a `NonNull` raw pointer. The // `.await` lowering will safely cast that back to a `&mut Context`. match this.0.resume(ResumeTy(NonNull::from(cx).cast::>())) { - GeneratorState::Yielded(()) => Poll::Pending, - GeneratorState::Complete(x) => Poll::Ready(x), + CoroutineState::Yielded(()) => Poll::Pending, + CoroutineState::Complete(x) => Poll::Ready(x), } } } @@ -395,7 +395,7 @@ mod future { mod stream { use core::{ future::Future, - ops::{Generator, GeneratorState}, + ops::{Coroutine, CoroutineState}, pin::Pin, ptr::NonNull, task::{Context, Poll}, @@ -406,15 +406,15 @@ mod stream { use crate::future::ResumeTy; - /// Wrap a generator in a stream. + /// Wrap a coroutine in a stream. /// /// This function returns a `GenStream` underneath, but hides it in `impl Trait` to give /// better error messages (`impl Stream` rather than `GenStream<[closure.....]>`). #[doc(hidden)] #[inline] - pub fn from_generator(gen: G) -> impl Stream + pub fn from_coroutine(gen: G) -> impl Stream where - G: Generator, Return = ()>, + G: Coroutine, Return = ()>, { GenStream(gen) } @@ -424,7 +424,7 @@ mod stream { impl Stream for GenStream where - G: Generator, Return = ()>, + G: Coroutine, Return = ()>, { type Item = T; @@ -432,8 +432,8 @@ mod stream { fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { let this = self.project(); match this.0.resume(ResumeTy(NonNull::from(cx).cast::>())) { - GeneratorState::Yielded(x) => x.map(Some), - GeneratorState::Complete(()) => Poll::Ready(None), + CoroutineState::Yielded(x) => x.map(Some), + CoroutineState::Complete(()) => Poll::Ready(None), } } } @@ -466,7 +466,7 @@ mod stream { mod try_stream { use core::{ - ops::{Generator, GeneratorState}, + ops::{Coroutine, CoroutineState}, pin::Pin, ptr::NonNull, task::{Context, Poll}, @@ -477,15 +477,15 @@ mod try_stream { use crate::future::ResumeTy; - /// Wrap a generator in a stream. + /// Wrap a coroutine in a stream. /// /// This function returns a `GenStream` underneath, but hides it in `impl Trait` to give /// better error messages (`impl Stream` rather than `GenStream<[closure.....]>`). #[doc(hidden)] #[inline] - pub fn from_generator(gen: G) -> impl FusedStream> + pub fn from_coroutine(gen: G) -> impl FusedStream> where - G: Generator, Return = Result<(), E>>, + G: Coroutine, Return = Result<(), E>>, { GenTryStream(Some(gen)) } @@ -495,7 +495,7 @@ mod try_stream { impl Stream for GenTryStream where - G: Generator, Return = Result<(), E>>, + G: Coroutine, Return = Result<(), E>>, { type Item = Result; @@ -504,9 +504,9 @@ mod try_stream { let mut this = self.project(); if let Some(gen) = this.0.as_mut().as_pin_mut() { let res = match gen.resume(ResumeTy(NonNull::from(cx).cast::>())) { - GeneratorState::Yielded(x) => x.map(|x| Some(Ok(x))), - GeneratorState::Complete(Err(e)) => Poll::Ready(Some(Err(e))), - GeneratorState::Complete(Ok(())) => Poll::Ready(None), + CoroutineState::Yielded(x) => x.map(|x| Some(Ok(x))), + CoroutineState::Complete(Err(e)) => Poll::Ready(Some(Err(e))), + CoroutineState::Complete(Ok(())) => Poll::Ready(None), }; if let Poll::Ready(Some(Err(_)) | None) = &res { this.0.set(None); @@ -520,7 +520,7 @@ mod try_stream { impl FusedStream for GenTryStream where - G: Generator, Return = Result<(), E>>, + G: Coroutine, Return = Result<(), E>>, { #[inline] fn is_terminated(&self) -> bool { @@ -548,7 +548,7 @@ pub mod __private { #[doc(hidden)] #[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/102352 - pub use crate::future::{from_generator, get_context, ResumeTy}; + pub use crate::future::{from_coroutine, get_context, ResumeTy}; } #[doc(hidden)] @@ -557,13 +557,13 @@ pub mod __private { pub use futures_core::stream::Stream; #[doc(hidden)] - pub use crate::stream::{from_generator, next}; + pub use crate::stream::{from_coroutine, next}; } #[doc(hidden)] pub mod try_stream { #[doc(hidden)] - pub use crate::try_stream::from_generator; + pub use crate::try_stream::from_coroutine; } } diff --git a/tests/elisions.rs b/tests/elisions.rs index 162959d..402d819 100644 --- a/tests/elisions.rs +++ b/tests/elisions.rs @@ -3,7 +3,7 @@ #![warn(rust_2018_idioms, single_use_lifetimes)] #![allow(clippy::needless_pass_by_value)] #![allow(clippy::needless_lifetimes)] // broken -#![feature(generators)] +#![feature(coroutines)] use futures_async_stream::stream; diff --git a/tests/for_await.rs b/tests/for_await.rs index 008a52c..a2a9245 100644 --- a/tests/for_await.rs +++ b/tests/for_await.rs @@ -2,7 +2,7 @@ #![warn(rust_2018_idioms, single_use_lifetimes)] #![allow(clippy::semicolon_if_nothing_returned)] // broken -#![feature(generators, proc_macro_hygiene, stmt_expr_attributes)] +#![feature(coroutines, proc_macro_hygiene, stmt_expr_attributes)] use futures::{ future::Future, diff --git a/tests/no-std/lib.rs b/tests/no-std/lib.rs index 11dc3a7..bc34086 100644 --- a/tests/no-std/lib.rs +++ b/tests/no-std/lib.rs @@ -2,7 +2,7 @@ #![no_std] #![warn(rust_2018_idioms, single_use_lifetimes)] -#![feature(generators)] +#![feature(coroutines)] use futures_async_stream::{stream, try_stream}; diff --git a/tests/overwriting_core_crate.rs b/tests/overwriting_core_crate.rs index 58f04be..deb6fce 100644 --- a/tests/overwriting_core_crate.rs +++ b/tests/overwriting_core_crate.rs @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT #![warn(rust_2018_idioms, single_use_lifetimes)] -#![feature(generators)] +#![feature(coroutines)] // See https://github.com/rust-lang/pin-utils/pull/26#discussion_r344491597 // diff --git a/tests/stream.rs b/tests/stream.rs index 5029b21..63b9f87 100644 --- a/tests/stream.rs +++ b/tests/stream.rs @@ -3,7 +3,7 @@ #![warn(rust_2018_idioms, single_use_lifetimes)] #![allow(clippy::unused_async)] #![allow(clippy::needless_lifetimes, clippy::semicolon_if_nothing_returned)] // broken -#![feature(generators, proc_macro_hygiene, stmt_expr_attributes, gen_future)] +#![feature(coroutines, proc_macro_hygiene, stmt_expr_attributes, gen_future)] use std::{pin::Pin, rc::Rc, sync::Arc}; diff --git a/tests/try_stream.rs b/tests/try_stream.rs index cd194e9..e88fbc0 100644 --- a/tests/try_stream.rs +++ b/tests/try_stream.rs @@ -3,7 +3,7 @@ #![warn(rust_2018_idioms, single_use_lifetimes)] #![allow(clippy::try_err, clippy::unused_async)] #![allow(clippy::semicolon_if_nothing_returned)] // broken -#![feature(generators, proc_macro_hygiene, stmt_expr_attributes)] +#![feature(coroutines, proc_macro_hygiene, stmt_expr_attributes)] use futures::{ future::Future, diff --git a/tests/ui/bad-item-type.rs b/tests/ui/bad-item-type.rs index 5343767..9e76b47 100644 --- a/tests/ui/bad-item-type.rs +++ b/tests/ui/bad-item-type.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT -#![feature(generators)] +#![feature(coroutines)] use futures_async_stream::stream; diff --git a/tests/ui/borrow-as-mut.rs b/tests/ui/borrow-as-mut.rs index 2fc404d..e7e63ff 100644 --- a/tests/ui/borrow-as-mut.rs +++ b/tests/ui/borrow-as-mut.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT -#![feature(generators)] +#![feature(coroutines)] use futures_async_stream::stream; diff --git a/tests/ui/def-site.rs b/tests/ui/def-site.rs index fc90bff..4b0590e 100644 --- a/tests/ui/def-site.rs +++ b/tests/ui/def-site.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT -#![feature(generators, proc_macro_hygiene, stmt_expr_attributes)] +#![feature(coroutines, proc_macro_hygiene, stmt_expr_attributes)] use futures_async_stream::{for_await, stream}; diff --git a/tests/ui/forget-semicolon.rs b/tests/ui/forget-semicolon.rs index 460e79a..d18b31d 100644 --- a/tests/ui/forget-semicolon.rs +++ b/tests/ui/forget-semicolon.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT -#![feature(generators)] +#![feature(coroutines)] use futures_async_stream::{stream, try_stream}; diff --git a/tests/ui/invalid-argument.rs b/tests/ui/invalid-argument.rs index d4878d4..c450525 100644 --- a/tests/ui/invalid-argument.rs +++ b/tests/ui/invalid-argument.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT -#![feature(generators, proc_macro_hygiene, stmt_expr_attributes)] +#![feature(coroutines, proc_macro_hygiene, stmt_expr_attributes)] mod for_await { use futures_async_stream::{for_await, stream}; diff --git a/tests/ui/invalid.rs b/tests/ui/invalid.rs index 3b83cc8..9152c67 100644 --- a/tests/ui/invalid.rs +++ b/tests/ui/invalid.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT -#![feature(generators, proc_macro_hygiene, stmt_expr_attributes)] +#![feature(coroutines, proc_macro_hygiene, stmt_expr_attributes)] mod signature { use futures_async_stream::stream; diff --git a/tests/ui/move-captured-variable.rs b/tests/ui/move-captured-variable.rs index 4a34ffb..9956832 100644 --- a/tests/ui/move-captured-variable.rs +++ b/tests/ui/move-captured-variable.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT -#![feature(generators)] +#![feature(coroutines)] use futures_async_stream::stream_block; diff --git a/tests/ui/move-captured-variable.stderr b/tests/ui/move-captured-variable.stderr index 9c83d32..84815e0 100644 --- a/tests/ui/move-captured-variable.stderr +++ b/tests/ui/move-captured-variable.stderr @@ -9,7 +9,7 @@ error[E0507]: cannot move out of `a`, a captured variable in an `FnMut` closure 13 | | yield a | | - | | | - | | variable moved due to use in generator + | | variable moved due to use in coroutine | | move occurs because `a` has type `String`, which does not implement the `Copy` trait 14 | | }; | |_________^ `a` is moved here diff --git a/tests/ui/nested.rs b/tests/ui/nested.rs index 1026552..73d297e 100644 --- a/tests/ui/nested.rs +++ b/tests/ui/nested.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT -#![feature(generators)] +#![feature(coroutines)] use futures_async_stream::stream; @@ -16,7 +16,7 @@ async fn _stream1() { async { #[for_await] for i in stream(2) { - yield i * i; //~ ERROR `async` generators are not yet supported [E0727] + yield i * i; //~ ERROR `async` coroutines are not yet supported [E0727] } } .await; diff --git a/tests/ui/nested.stderr b/tests/ui/nested.stderr index 2d72b29..00842b5 100644 --- a/tests/ui/nested.stderr +++ b/tests/ui/nested.stderr @@ -1,11 +1,11 @@ -error[E0727]: `async` generators are not yet supported +error[E0727]: `async` coroutines are not yet supported --> tests/ui/nested.rs:19:13 | -19 | yield i * i; //~ ERROR `async` generators are not yet supported [E0727] +19 | yield i * i; //~ ERROR `async` coroutines are not yet supported [E0727] | ^^^^^^^^^^^ error[E0308]: mismatched types --> tests/ui/nested.rs:19:19 | -19 | yield i * i; //~ ERROR `async` generators are not yet supported [E0727] +19 | yield i * i; //~ ERROR `async` coroutines are not yet supported [E0727] | ^^^^^ expected `()`, found `i32` diff --git a/tests/ui/question-mark-await-type-error.rs b/tests/ui/question-mark-await-type-error.rs index dfeb225..0c83c42 100644 --- a/tests/ui/question-mark-await-type-error.rs +++ b/tests/ui/question-mark-await-type-error.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT -#![feature(generators, proc_macro_hygiene, stmt_expr_attributes)] +#![feature(coroutines, proc_macro_hygiene, stmt_expr_attributes)] use futures_async_stream::{for_await, stream}; diff --git a/tests/ui/question-mark-await-type-error.stderr b/tests/ui/question-mark-await-type-error.stderr index 6c2e43c..0d2007a 100644 --- a/tests/ui/question-mark-await-type-error.stderr +++ b/tests/ui/question-mark-await-type-error.stderr @@ -28,14 +28,14 @@ error[E0277]: the `?` operator can only be applied to values that implement `Try | = help: the trait `Try` is not implemented for `()` -error[E0277]: the `?` operator can only be used in a generator that returns `Result` or `Option` (or another type that implements `FromResidual`) +error[E0277]: the `?` operator can only be used in a coroutine that returns `Result` or `Option` (or another type that implements `FromResidual`) --> tests/ui/question-mark-await-type-error.rs:23:23 | 20 | #[stream(item = i32)] | --------------------- this function should return `Result` or `Option` to accept `?` ... 23 | async {}.await?; //~ ERROR the `?` operator can only be applied to values that implement `std::ops::Try` - | ^ cannot use the `?` operator in a generator that returns `()` + | ^ cannot use the `?` operator in a coroutine that returns `()` | = help: the trait `FromResidual<_>` is not implemented for `()` @@ -70,13 +70,13 @@ error[E0277]: the `?` operator can only be applied to values that implement `Try | = help: the trait `Try` is not implemented for `()` -error[E0277]: the `?` operator can only be used in a generator that returns `Result` or `Option` (or another type that implements `FromResidual`) +error[E0277]: the `?` operator can only be used in a coroutine that returns `Result` or `Option` (or another type that implements `FromResidual`) --> tests/ui/question-mark-await-type-error.rs:38:23 | 34 | #[stream(item = i32)] | --------------------- this function should return `Result` or `Option` to accept `?` ... 38 | async {}.await?; //~ ERROR the `?` operator can only be applied to values that implement `std::ops::Try` - | ^ cannot use the `?` operator in a generator that returns `()` + | ^ cannot use the `?` operator in a coroutine that returns `()` | = help: the trait `FromResidual<_>` is not implemented for `()` diff --git a/tests/ui/threads-safety.rs b/tests/ui/threads-safety.rs index 28f5538..6e193f2 100644 --- a/tests/ui/threads-safety.rs +++ b/tests/ui/threads-safety.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT -#![feature(generators)] +#![feature(coroutines)] use futures_async_stream::stream; diff --git a/tests/ui/type-error.rs b/tests/ui/type-error.rs index 54afe03..fd58322 100644 --- a/tests/ui/type-error.rs +++ b/tests/ui/type-error.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT -#![feature(generators)] +#![feature(coroutines)] use futures_async_stream::stream; diff --git a/tests/ui/unresolved-type.rs b/tests/ui/unresolved-type.rs index ecb26f3..40efa45 100644 --- a/tests/ui/unresolved-type.rs +++ b/tests/ui/unresolved-type.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT -#![feature(generators)] +#![feature(coroutines)] use futures_async_stream::stream;