Skip to content

Commit 7c70cbb

Browse files
committed
Error on using yield without also using #[coroutine] on the closure
And suggest adding the `#[coroutine]` to the closure
1 parent b8dab92 commit 7c70cbb

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

core/src/iter/sources/from_coroutine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::pin::Pin;
1414
/// #![feature(coroutines)]
1515
/// #![feature(iter_from_coroutine)]
1616
///
17-
/// let it = std::iter::from_coroutine(|| {
17+
/// let it = std::iter::from_coroutine(#[cfg_attr(not(bootstrap), coroutine)] || {
1818
/// yield 1;
1919
/// yield 2;
2020
/// yield 3;

core/src/ops/coroutine.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ pub enum CoroutineState<Y, R> {
4040
/// ```rust
4141
/// #![feature(coroutines)]
4242
/// #![feature(coroutine_trait)]
43+
/// #![feature(stmt_expr_attributes)]
4344
///
4445
/// use std::ops::{Coroutine, CoroutineState};
4546
/// use std::pin::Pin;
4647
///
4748
/// fn main() {
48-
/// let mut coroutine = || {
49+
/// let mut coroutine = #[cfg_attr(not(bootstrap), coroutine)] || {
4950
/// yield 1;
5051
/// "foo"
5152
/// };

core/src/pin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,7 @@ impl<Ptr, U> DispatchFromDyn<Pin<U>> for Pin<Ptr> where Ptr: DispatchFromDyn<U>
18091809
/// fn coroutine_fn() -> impl Coroutine<Yield = usize, Return = ()> /* not Unpin */ {
18101810
/// // Allow coroutine to be self-referential (not `Unpin`)
18111811
/// // vvvvvv so that locals can cross yield points.
1812-
/// static || {
1812+
/// #[cfg_attr(not(bootstrap), coroutine)] static || {
18131813
/// let foo = String::from("foo");
18141814
/// let foo_ref = &foo; // ------+
18151815
/// yield 0; // | <- crosses yield point!

0 commit comments

Comments
 (0)