diff --git a/futures-async-macro/README.md b/futures-async-macro/README.md index 598bec6141..6753080ddd 100644 --- a/futures-async-macro/README.md +++ b/futures-async-macro/README.md @@ -34,18 +34,18 @@ This is a reimplement of [futures-await]'s `#[async_stream]` for futures 0.3 and ```rust use futures::prelude::*; -use futures::{async_stream, stream_yield}; +use futures::async_stream; // Returns a stream of i32 #[async_stream] fn foo(stream: impl Stream) -> i32 { #[for_await] for x in stream { - stream_yield!(x.parse().unwrap()); + yield x.parse().unwrap(); } } ``` -`#[async_stream]` have an item type specified via `-> some::Path` and the values output from the stream must be yielded via the `stream_yield!` macro. +`#[async_stream]` have an item type specified via `-> some::Path` and the values output from the stream must be yielded via the `yield` expression. [futures-await]: https://github.com/alexcrichton/futures-await diff --git a/futures-async-macro/src/error.rs b/futures-async-macro/src/error.rs index 19534dd116..cfedc1105f 100644 --- a/futures-async-macro/src/error.rs +++ b/futures-async-macro/src/error.rs @@ -41,12 +41,3 @@ macro_rules! outside_of_async_error { )) }; } - -macro_rules! outside_of_async_stream_error { - ($tokens:expr, $name:expr) => { - $crate::error::expr_compile_error(&syn::Error::new_spanned( - $tokens, - concat!($name, " cannot be allowed outside of async_stream blocks, and functions."), - )) - }; -} diff --git a/futures-async-macro/src/lib.rs b/futures-async-macro/src/lib.rs index 321357b545..5a7422f324 100644 --- a/futures-async-macro/src/lib.rs +++ b/futures-async-macro/src/lib.rs @@ -10,8 +10,8 @@ use proc_macro2::{Span, TokenStream as TokenStream2, TokenTree as TokenTree2}; use quote::{quote, ToTokens}; use syn::{ fold::{self, Fold}, - token, ArgCaptured, Error, Expr, ExprForLoop, ExprMacro, FnArg, FnDecl, Ident, Item, ItemFn, - Pat, PatIdent, ReturnType, TypeTuple, + token, ArgCaptured, Error, Expr, ExprForLoop, ExprMacro, ExprYield, FnArg, FnDecl, Ident, Item, + ItemFn, Pat, PatIdent, ReturnType, TypeTuple, }; #[macro_use] @@ -276,9 +276,6 @@ impl Expand { }} } - /* TODO: If this is enabled, it can be used for `yield` instead of `stream_yield!`. - Raw `yield` is simpler, but it may be preferable to distinguish it from `yield` called - in other scopes. /// Expands `yield expr` in `async_stream` scope. fn expand_yield(&self, expr: ExprYield) -> ExprYield { if self.0 != Stream { @@ -292,7 +289,6 @@ impl Expand { }; ExprYield { attrs, yield_token, expr: Some(Box::new(expr)) } } - */ /// Expands a macro. fn expand_macro(&mut self, mut expr: ExprMacro) -> Expr { @@ -307,10 +303,6 @@ impl Expand { } else { unreachable!() } - } else if self.0 != Stream && expr.mac.path.is_ident("stream_yield") { - // TODO: Should we remove real `stream_yield!` macro and replace `stream_yield!` call in - // here? -- or should we use `yield` instead of ``? - return outside_of_async_stream_error!(expr, "stream_yield!"); } Expr::Macro(expr) @@ -360,7 +352,7 @@ impl Fold for Expand { let expr = match fold::fold_expr(self, expr) { Expr::ForLoop(expr) => self.expand_for_await(expr), - // Expr::Yield(expr) => Expr::Yield(self.expand_yield(expr)), + Expr::Yield(expr) => Expr::Yield(self.expand_yield(expr)), Expr::Macro(expr) => self.expand_macro(expr), expr => expr, }; diff --git a/futures-util/src/async_stream/mod.rs b/futures-util/src/async_stream/mod.rs index a8ca435bc1..1391ab4a4a 100644 --- a/futures-util/src/async_stream/mod.rs +++ b/futures-util/src/async_stream/mod.rs @@ -3,10 +3,6 @@ //! This module contains a number of functions and combinators for working //! with `async`/`await` code. -#[macro_use] -mod stream_yield; -pub use self::stream_yield::*; - use futures_core::future::Future; use futures_core::stream::Stream; use std::future::{self, get_task_context, set_task_context}; diff --git a/futures-util/src/async_stream/stream_yield.rs b/futures-util/src/async_stream/stream_yield.rs deleted file mode 100644 index 9cabccf0e6..0000000000 --- a/futures-util/src/async_stream/stream_yield.rs +++ /dev/null @@ -1,24 +0,0 @@ -/// Yield an item from an `#[async_stream]` function. -/// -/// # Examples -/// -/// ```no-run -/// #![feature(futures_api, generators)] -/// use futures::prelude::*; -/// use futures::executor::block_on; -/// use futures::{async_stream, stream_yield}; -/// -/// #[async_stream] -/// fn one_five() -> u32 { -/// stream_yield!(1); -/// stream_yield!(5); -/// } -/// -/// assert_eq!(vec![1, 5], block_on(one_five().collect::>())); -/// ``` -#[macro_export] -macro_rules! stream_yield { - ($e:expr) => {{ - yield $crate::core_reexport::task::Poll::Ready($e) - }} -} diff --git a/futures/src/lib.rs b/futures/src/lib.rs index 0d7d6764d7..84f77a9f73 100644 --- a/futures/src/lib.rs +++ b/futures/src/lib.rs @@ -68,8 +68,6 @@ pub use futures_util::{ }; // Async stream #[cfg(feature = "async-stream")] -pub use futures_util::stream_yield; -#[cfg(feature = "async-stream")] #[doc(hidden)] pub use futures_util::async_stream; #[cfg(feature = "async-stream")] diff --git a/futures/testcrate/ui/bad-input-1.rs b/futures/testcrate/ui/bad-input-1.rs deleted file mode 100644 index 3087bb8720..0000000000 --- a/futures/testcrate/ui/bad-input-1.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(async_await, futures_api, generators)] - -use futures::*; - -#[async_stream] -fn foo() -> i32 { - #[for_await] - for i in stream::iter(vec![1, 2]) { - stream_yield!(bar!!()); - } -} - -fn main() {} diff --git a/futures/testcrate/ui/bad-input-1.stderr b/futures/testcrate/ui/bad-input-1.stderr deleted file mode 100644 index a285c24da7..0000000000 --- a/futures/testcrate/ui/bad-input-1.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: expected open delimiter - --> $DIR/bad-input-1.rs:9:27 - | -9 | stream_yield!(bar!!()); - | ^ expected open delimiter - -error: aborting due to previous error - diff --git a/futures/testcrate/ui/bad-input-2.rs b/futures/testcrate/ui/bad-input.rs similarity index 84% rename from futures/testcrate/ui/bad-input-2.rs rename to futures/testcrate/ui/bad-input.rs index 945414da9c..8c64129b49 100644 --- a/futures/testcrate/ui/bad-input-2.rs +++ b/futures/testcrate/ui/bad-input.rs @@ -7,7 +7,7 @@ use futures::*; fn foo() -> i32 { #[for_await(bar)] for i in stream::iter(vec![1, 2]) { - stream_yield!(i); + yield i; } } @@ -15,7 +15,7 @@ fn foo() -> i32 { fn bar() -> i32 { #[for_await] for i in stream::iter(vec![1, 2]) { - stream_yield!(i); + yield i; } } diff --git a/futures/testcrate/ui/bad-input-2.stderr b/futures/testcrate/ui/bad-input.stderr similarity index 81% rename from futures/testcrate/ui/bad-input-2.stderr rename to futures/testcrate/ui/bad-input.stderr index 161240539a..76a83516d1 100644 --- a/futures/testcrate/ui/bad-input-2.stderr +++ b/futures/testcrate/ui/bad-input.stderr @@ -1,11 +1,11 @@ error: attribute must be of the form `#[for_await]` - --> $DIR/bad-input-2.rs:8:5 + --> $DIR/bad-input.rs:8:5 | 8 | #[for_await(bar)] | ^^^^^^^^^^^^^^^^^ error: attribute must be of the form `#[async_stream]` - --> $DIR/bad-input-2.rs:14:1 + --> $DIR/bad-input.rs:14:1 | 14 | #[async_stream(baz)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/futures/testcrate/ui/bad-return-type.rs b/futures/testcrate/ui/bad-return-type.rs index fbaf06801a..6fc64107ae 100644 --- a/futures/testcrate/ui/bad-return-type.rs +++ b/futures/testcrate/ui/bad-return-type.rs @@ -6,19 +6,19 @@ use futures::*; fn foobar() -> Option { let val = Some(42); if val.is_none() { - stream_yield!(None); + yield None; return; } let val = val.unwrap(); - stream_yield!(val); + yield val; } #[async_stream] fn tuple() -> (i32, i32) { if false { - stream_yield!(3); + yield 3; } - stream_yield!((1, 2)) + yield (1, 2) } fn main() {} diff --git a/futures/testcrate/ui/bad-return-type.stderr b/futures/testcrate/ui/bad-return-type.stderr index 5da8b2e357..cd9d36e90f 100644 --- a/futures/testcrate/ui/bad-return-type.stderr +++ b/futures/testcrate/ui/bad-return-type.stderr @@ -1,11 +1,11 @@ error[E0308]: mismatched types - --> $DIR/bad-return-type.rs:13:19 + --> $DIR/bad-return-type.rs:13:11 | -13 | stream_yield!(val); - | ^^^ - | | - | expected enum `std::option::Option`, found integer - | help: try using a variant of the expected type: `Some(val)` +13 | yield val; + | ^^^ + | | + | expected enum `std::option::Option`, found integer + | help: try using a variant of the expected type: `Some(val)` | = note: expected type `std::option::Option<_>` found type `{integer}` @@ -17,11 +17,10 @@ error[E0698]: type inside generator must be known in this context | ^^^ | note: the type is part of the generator because of this `yield` - --> $DIR/bad-return-type.rs:13:5 + --> $DIR/bad-return-type.rs:5:1 | -13| stream_yield!(val); - | ^^^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) +5 | #[async_stream] + | ^^^^^^^^^^^^^^^ error[E0698]: type inside generator must be known in this context --> $DIR/bad-return-type.rs:12:9 @@ -30,30 +29,28 @@ error[E0698]: type inside generator must be known in this context | ^^^ | note: the type is part of the generator because of this `yield` - --> $DIR/bad-return-type.rs:13:5 + --> $DIR/bad-return-type.rs:5:1 | -13 | stream_yield!(val); - | ^^^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) +5 | #[async_stream] + | ^^^^^^^^^^^^^^^ error[E0698]: type inside generator must be known in this context - --> $DIR/bad-return-type.rs:13:19 + --> $DIR/bad-return-type.rs:13:11 | -13 | stream_yield!(val); - | ^^^ +13 | yield val; + | ^^^ | note: the type is part of the generator because of this `yield` - --> $DIR/bad-return-type.rs:13:5 + --> $DIR/bad-return-type.rs:5:1 | -13 | stream_yield!(val); - | ^^^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) +5 | #[async_stream] + | ^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/bad-return-type.rs:21:19 + --> $DIR/bad-return-type.rs:21:11 | -21 | stream_yield!((1, 2)) - | ^^^^^^ expected integer, found tuple +21 | yield (1, 2) + | ^^^^^^ expected integer, found tuple | = note: expected type `{integer}` found type `({integer}, {integer})` @@ -69,114 +66,58 @@ error[E0271]: type mismatch resolving ` $DIR/bad-return-type.rs:19:9 - | -19 | stream_yield!(3); - | ^^^^^^^^^^^^^^^^^ - | -note: the type is part of the generator because of this `yield` - --> $DIR/bad-return-type.rs:19:9 - | -19 | stream_yield!(3); - | ^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error[E0698]: type inside generator must be known in this context - --> $DIR/bad-return-type.rs:19:23 - | -19 | stream_yield!(3); - | ^ - | -note: the type is part of the generator because of this `yield` - --> $DIR/bad-return-type.rs:19:9 - | -19 | stream_yield!(3); - | ^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error[E0698]: type inside generator must be known in this context - --> $DIR/bad-return-type.rs:19:9 - | -19 | stream_yield!(3); - | ^^^^^^^^^^^^^^^^^ - | -note: the type is part of the generator because of this `yield` - --> $DIR/bad-return-type.rs:19:9 - | -19 | stream_yield!(3); - | ^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error[E0698]: type inside generator must be known in this context - --> $DIR/bad-return-type.rs:21:5 - | -21 | stream_yield!((1, 2)) - | ^^^^^^^^^^^^^^^^^^^^^ - | -note: the type is part of the generator because of this `yield` - --> $DIR/bad-return-type.rs:21:5 - | -21 | stream_yield!((1, 2)) - | ^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error[E0698]: type inside generator must be known in this context - --> $DIR/bad-return-type.rs:21:20 + --> $DIR/bad-return-type.rs:16:1 | -21 | stream_yield!((1, 2)) - | ^ +16 | #[async_stream] + | ^^^^^^^^^^^^^^^ | note: the type is part of the generator because of this `yield` - --> $DIR/bad-return-type.rs:21:5 + --> $DIR/bad-return-type.rs:16:1 | -21 | stream_yield!((1, 2)) - | ^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) +16 | #[async_stream] + | ^^^^^^^^^^^^^^^ error[E0698]: type inside generator must be known in this context - --> $DIR/bad-return-type.rs:21:23 + --> $DIR/bad-return-type.rs:19:15 | -21 | stream_yield!((1, 2)) - | ^ +19 | yield 3; + | ^ | note: the type is part of the generator because of this `yield` - --> $DIR/bad-return-type.rs:21:5 + --> $DIR/bad-return-type.rs:16:1 | -21 | stream_yield!((1, 2)) - | ^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) +16 | #[async_stream] + | ^^^^^^^^^^^^^^^ error[E0698]: type inside generator must be known in this context - --> $DIR/bad-return-type.rs:21:19 + --> $DIR/bad-return-type.rs:21:12 | -21 | stream_yield!((1, 2)) - | ^^^^^^ +21 | yield (1, 2) + | ^ | note: the type is part of the generator because of this `yield` - --> $DIR/bad-return-type.rs:21:5 + --> $DIR/bad-return-type.rs:16:1 | -21 | stream_yield!((1, 2)) - | ^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) +16 | #[async_stream] + | ^^^^^^^^^^^^^^^ error[E0698]: type inside generator must be known in this context - --> $DIR/bad-return-type.rs:21:5 + --> $DIR/bad-return-type.rs:21:15 | -21 | stream_yield!((1, 2)) - | ^^^^^^^^^^^^^^^^^^^^^ +21 | yield (1, 2) + | ^ | note: the type is part of the generator because of this `yield` - --> $DIR/bad-return-type.rs:21:5 - | -21 | stream_yield!((1, 2)) - | ^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error[E0698]: type inside generator must be known in this context --> $DIR/bad-return-type.rs:16:1 | 16 | #[async_stream] | ^^^^^^^^^^^^^^^ + +error[E0698]: type inside generator must be known in this context + --> $DIR/bad-return-type.rs:21:11 + | +21 | yield (1, 2) + | ^^^^^^ | note: the type is part of the generator because of this `yield` --> $DIR/bad-return-type.rs:16:1 @@ -184,7 +125,7 @@ note: the type is part of the generator because of this `yield` 16 | #[async_stream] | ^^^^^^^^^^^^^^^ -error: aborting due to 15 previous errors +error: aborting due to 11 previous errors Some errors have detailed explanations: E0271, E0308. For more information about an error, try `rustc --explain E0271`. diff --git a/futures/testcrate/ui/forget-semicolon.rs b/futures/testcrate/ui/forget-semicolon.rs index c01ad7e6af..ccda64f725 100644 --- a/futures/testcrate/ui/forget-semicolon.rs +++ b/futures/testcrate/ui/forget-semicolon.rs @@ -4,7 +4,7 @@ use futures::*; #[async_stream] fn foo() { - stream_yield!(()); + yield; Some(()) } diff --git a/futures/testcrate/ui/move-captured-variable.rs b/futures/testcrate/ui/move-captured-variable.rs index 202d32af75..74e1754014 100644 --- a/futures/testcrate/ui/move-captured-variable.rs +++ b/futures/testcrate/ui/move-captured-variable.rs @@ -8,7 +8,7 @@ fn main() { let a = String::new(); foo(|| { async_stream_block! { - stream_yield!(a) + yield a }; }); } diff --git a/futures/testcrate/ui/move-captured-variable.stderr b/futures/testcrate/ui/move-captured-variable.stderr index 7b48d6fba9..bacd96c626 100644 --- a/futures/testcrate/ui/move-captured-variable.stderr +++ b/futures/testcrate/ui/move-captured-variable.stderr @@ -5,7 +5,7 @@ error[E0507]: cannot move out of captured variable in an `FnMut` closure | - captured outer variable 9 | foo(|| { 10 | / async_stream_block! { -11 | | stream_yield!(a) +11 | | yield a 12 | | }; | |__________^ cannot move out of captured variable in an `FnMut` closure diff --git a/futures/testcrate/ui/nested.rs b/futures/testcrate/ui/nested.rs index 604bcd31cd..762f658c79 100644 --- a/futures/testcrate/ui/nested.rs +++ b/futures/testcrate/ui/nested.rs @@ -7,7 +7,7 @@ fn _stream1() -> i32 { let _ = async { #[for_await] for i in stream::iter(vec![1, 2]) { - stream_yield!(i * i); + yield i * i; } }; } diff --git a/futures/testcrate/ui/nested.stderr b/futures/testcrate/ui/nested.stderr index dfbe4390fe..c437395e22 100644 --- a/futures/testcrate/ui/nested.stderr +++ b/futures/testcrate/ui/nested.stderr @@ -1,8 +1,11 @@ -error: stream_yield! cannot be allowed outside of async_stream blocks, and functions. - --> $DIR/nested.rs:10:13 +error[E0308]: mismatched types + --> $DIR/nested.rs:10:19 + | +10 | yield i * i; + | ^^^^^ expected (), found integer | -10 | stream_yield!(i * i); - | ^^^^^^^^^^^^^^^^^^^^^ + = note: expected type `()` + found type `{integer}` error[E0698]: type inside generator must be known in this context --> $DIR/nested.rs:5:1 @@ -11,10 +14,71 @@ error[E0698]: type inside generator must be known in this context | ^^^^^^^^^^^^^^^ | note: the type is part of the generator because of this `yield` + --> $DIR/nested.rs:10:13 + | +10| yield i * i; + | ^^^^^^^^^^^ + +error[E0698]: type inside generator must be known in this context --> $DIR/nested.rs:5:1 | 5 | #[async_stream] | ^^^^^^^^^^^^^^^ + | +note: the type is part of the generator because of this `yield` + --> $DIR/nested.rs:5:1 + | +5 | #[async_stream] + | ^^^^^^^^^^^^^^^ + +error[E0698]: type inside generator must be known in this context + --> $DIR/nested.rs:9:13 + | +9 | for i in stream::iter(vec![1, 2]) { + | ^ + | +note: the type is part of the generator because of this `yield` + --> $DIR/nested.rs:10:13 + | +10| yield i * i; + | ^^^^^^^^^^^ + +error[E0698]: type inside generator must be known in this context + --> $DIR/nested.rs:10:19 + | +10 | yield i * i; + | ^ + | +note: the type is part of the generator because of this `yield` + --> $DIR/nested.rs:10:13 + | +10 | yield i * i; + | ^^^^^^^^^^^ + +error[E0698]: type inside generator must be known in this context + --> $DIR/nested.rs:10:23 + | +10 | yield i * i; + | ^ + | +note: the type is part of the generator because of this `yield` + --> $DIR/nested.rs:10:13 + | +10 | yield i * i; + | ^^^^^^^^^^^ + +error[E0698]: type inside generator must be known in this context + --> $DIR/nested.rs:10:19 + | +10 | yield i * i; + | ^^^^^ + | +note: the type is part of the generator because of this `yield` + --> $DIR/nested.rs:10:13 + | +10 | yield i * i; + | ^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 7 previous errors +For more information about this error, try `rustc --explain E0308`. diff --git a/futures/testcrate/ui/type_error.rs b/futures/testcrate/ui/type_error.rs index 202d38b6ae..3a1e827969 100644 --- a/futures/testcrate/ui/type_error.rs +++ b/futures/testcrate/ui/type_error.rs @@ -5,7 +5,7 @@ use futures::*; #[async_stream] fn foo() -> i32 { let a: i32 = "a"; //~ ERROR: mismatched types - stream_yield!(1); + yield 1; } fn main() {} diff --git a/futures/tests/async_stream/elisions.rs b/futures/tests/async_stream/elisions.rs index 9d3eafe614..03e648ff8f 100644 --- a/futures/tests/async_stream/elisions.rs +++ b/futures/tests/async_stream/elisions.rs @@ -5,12 +5,12 @@ struct Ref<'a, T>(&'a T); #[async_stream] fn references(x: &i32) -> i32 { - stream_yield!(*x); + yield *x; } #[async_stream] fn new_types(x: Ref<'_, i32>) -> i32 { - stream_yield!(*x.0); + yield *x.0; } struct Foo(i32); @@ -18,18 +18,18 @@ struct Foo(i32); impl Foo { #[async_stream] fn foo(&self) -> &i32 { - stream_yield!(&self.0) + yield &self.0 } } #[async_stream] fn single_ref(x: &i32) -> &i32 { - stream_yield!(x) + yield x } #[async_stream] fn check_for_name_colision<'_async0, T>(_x: &T, _y: &'_async0 i32) { - stream_yield!(()) + yield } #[test] diff --git a/futures/tests/async_stream/pinned.rs b/futures/tests/async_stream/pinned.rs index 42a271b678..d407262f90 100644 --- a/futures/tests/async_stream/pinned.rs +++ b/futures/tests/async_stream/pinned.rs @@ -7,15 +7,15 @@ fn stream1() -> u64 { 1 } let x = &integer(); - stream_yield!(0); - stream_yield!(*x); + yield 0; + yield *x; } fn stream1_block() -> impl Stream { async_stream_block! { #[for_await] for item in stream1() { - stream_yield!(item) + yield item } } } diff --git a/futures/tests/async_stream/smoke.rs b/futures/tests/async_stream/smoke.rs index 9dae1e86f9..c13bf57a3a 100644 --- a/futures/tests/async_stream/smoke.rs +++ b/futures/tests/async_stream/smoke.rs @@ -17,14 +17,14 @@ async fn future1() -> i32 { #[async_stream] fn stream1() -> u64 { - stream_yield!(0); - stream_yield!(1); + yield 0; + yield 1; } #[async_stream] fn stream2(t: T) -> T { - stream_yield!(t.clone()); - stream_yield!(t.clone()); + yield t.clone(); + yield t.clone(); } #[async_stream] @@ -33,9 +33,9 @@ fn stream3() -> i32 { #[for_await] for x in stream::iter(vec![1, 2, 3, 4]) { cnt += x; - stream_yield!(x); + yield x; } - stream_yield!(cnt); + yield cnt; } mod foo { @@ -44,26 +44,26 @@ mod foo { #[async_stream] fn _stream5() -> foo::_Foo { - stream_yield!(foo::_Foo(0)); - stream_yield!(foo::_Foo(1)); + yield foo::_Foo(0); + yield foo::_Foo(1); } #[async_stream] fn _stream6() -> i32 { #[for_await] for foo::_Foo(i) in _stream5() { - stream_yield!(i * i); + yield i * i; } } #[async_stream] fn _stream7() -> () { - stream_yield!(()); + yield (); } #[async_stream] fn _stream8() -> [u32; 4] { - stream_yield!([1, 2, 3, 4]); + yield [1, 2, 3, 4]; } struct A(i32); @@ -71,12 +71,12 @@ struct A(i32); impl A { #[async_stream] fn a_foo(self) -> i32 { - stream_yield!(self.0) + yield self.0 } #[async_stream] fn _a_foo2(self: Box) -> i32 { - stream_yield!(self.0) + yield self.0 } } @@ -100,7 +100,7 @@ fn main() { // https://github.com/alexcrichton/futures-await/issues/45 #[async_stream] fn _stream10() { - stream_yield!(()); + yield; } block_on(async {