Skip to content

Commit

Permalink
Fix build failure on latest nightly
Browse files Browse the repository at this point in the history
```
error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
 --> tests/no-std/../include/basic.rs:3:1
  |
3 | #[stream(item = ())]
  | ^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the attribute macro `stream` (in Nightly builds, run with -Z macro-backtrace for more info)
help: use `#[coroutine]` to make this closure a coroutine
  |
3 | #[coroutine] #[stream(item = ())]
  | ++++++++++++

error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
 --> tests/no-std/../include/basic.rs:6:1
  |
6 | #[stream(item = ())]
  | ^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the attribute macro `stream` (in Nightly builds, run with -Z macro-backtrace for more info)
help: use `#[coroutine]` to make this closure a coroutine
  |
6 | #[coroutine] #[stream(item = ())]
  | ++++++++++++

error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
  --> tests/no-std/../include/basic.rs:17:1
   |
17 | #[try_stream(ok = (), error = ())]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the attribute macro `try_stream` (in Nightly builds, run with -Z macro-backtrace for more info)
help: use `#[coroutine]` to make this closure a coroutine
   |
17 | #[coroutine] #[try_stream(ok = (), error = ())]
   | ++++++++++++

error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
  --> tests/no-std/../include/basic.rs:28:1
   |
28 | #[stream(item = ())]
   | ^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the attribute macro `stream` (in Nightly builds, run with -Z macro-backtrace for more info)
help: use `#[coroutine]` to make this closure a coroutine
   |
28 | #[coroutine] #[stream(item = ())]
   | ++++++++++++

error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
  --> tests/no-std/../include/basic.rs:41:1
   |
41 | #[try_stream(ok = (), error = ())]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the attribute macro `try_stream` (in Nightly builds, run with -Z macro-backtrace for more info)
help: use `#[coroutine]` to make this closure a coroutine
   |
41 | #[coroutine] #[try_stream(ok = (), error = ())]
   | ++++++++++++

error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
  --> tests/no-std/../include/basic.rs:54:1
   |
54 | #[stream(item = ())]
   | ^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the attribute macro `stream` (in Nightly builds, run with -Z macro-backtrace for more info)
help: use `#[coroutine]` to make this closure a coroutine
   |
54 | #[coroutine] #[stream(item = ())]
   | ++++++++++++

error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
  --> tests/no-std/../include/basic.rs:69:1
   |
69 | #[try_stream(ok = (), error = ())]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the attribute macro `try_stream` (in Nightly builds, run with -Z macro-backtrace for more info)
help: use `#[coroutine]` to make this closure a coroutine
   |
69 | #[coroutine] #[try_stream(ok = (), error = ())]
   | ++++++++++++
```
  • Loading branch information
taiki-e committed Apr 27, 2024
1 parent ea8cbab commit 20c333e
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ disallowed-methods = [
{ path = "std::env::set_var", reason = "this is not thread-safe and inherently unsafe; see <https://github.com/rust-lang/rust/issues/27970> for more" },
]
disallowed-types = []
msrv = "1.74" # nightly-2023-10-29 is 1.75 but not full 1.75 since it is nightly.
msrv = "1.78" # nightly-2024-04-25 is 1.79 but not full 1.79 since it is nightly.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
# This is the minimum supported Rust version of this crate.
# When updating this, the reminder to update the minimum supported
# Rust version in README.md and .clippy.toml.
- nightly-2023-10-29
- nightly-2024-04-25
- nightly
runs-on: ubuntu-latest
timeout-minutes: 60
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

## [Unreleased]

- Fix build failure on latest nightly (nightly-2024-04-25+). ([#97](https://github.com/taiki-e/futures-async-stream/issues/97))

## [0.2.10] - 2024-01-12

- Fix "unexpected token" error on the comma following the async block. ([#94](https://github.com/taiki-e/futures-async-stream/pull/94), thanks @ethe)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ futures-async-stream = "0.2"
futures = "0.3"
```

*Compiler support: requires rustc nightly-2023-10-29+*
*Compiler support: requires rustc nightly-2024-04-25+*

## `#[for_await]`

Expand Down
3 changes: 2 additions & 1 deletion futures-async-stream-macro/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ fn expand_async_body(inputs: Punctuated<FnArg, Token![,]>) -> (Vec<FnArg>, Vec<S
// into:
//
// fn foo(self: <ty>, mut __arg1: <ty>) -> impl Stream<Item = u32> {
// from_coroutine(static move || {
// from_coroutine(#[coroutine] static move || {
// let ref <ident> = __arg1;
//
// // ...
Expand Down Expand Up @@ -375,6 +375,7 @@ fn make_gen_body(
let task_context = def_site_ident!("__task_context");
let body = quote! {
#gen_function(
#[coroutine]
static #capture |
mut #task_context: ::futures_async_stream::__private::future::ResumeTy,
| -> #ret_ty {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ futures-async-stream = "0.2"
futures = "0.3"
```
*Compiler support: requires rustc nightly-2023-10-29+*
*Compiler support: requires rustc nightly-2024-04-25+*
## `#[for_await]`
Expand Down

0 comments on commit 20c333e

Please sign in to comment.