Skip to content

Commit dda4709

Browse files
committed
Error on using yield without also using #[coroutine] on the closure
And suggest adding the `#[coroutine]` to the closure
1 parent 36449f8 commit dda4709

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

example/polymorphize_coroutine.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(coroutines, coroutine_trait)]
1+
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
22

33
use std::ops::Coroutine;
44
use std::pin::Pin;
@@ -8,7 +8,8 @@ fn main() {
88
}
99

1010
fn run_coroutine<T>() {
11-
let mut coroutine = || {
11+
let mut coroutine = #[coroutine]
12+
|| {
1213
yield;
1314
return;
1415
};

example/std_example.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![feature(
22
core_intrinsics,
33
coroutines,
4+
stmt_expr_attributes,
45
coroutine_trait,
56
is_sorted,
67
repr_simd,
@@ -123,9 +124,12 @@ fn main() {
123124
test_simd();
124125
}
125126

126-
Box::pin(move |mut _task_context| {
127-
yield ();
128-
})
127+
Box::pin(
128+
#[coroutine]
129+
move |mut _task_context| {
130+
yield ();
131+
},
132+
)
129133
.as_mut()
130134
.resume(0);
131135

0 commit comments

Comments
 (0)