about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-04-11 13:15:34 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-04-24 08:05:29 +0000
commitdda4709b1cba078ab05a32aa9c9359537e0ae0ad (patch)
treef4fac428583c9bf94480ded07ee7734df21a3c72
parent36449f8cd6a2166dec0799499218f89e2b25402c (diff)
downloadrust-dda4709b1cba078ab05a32aa9c9359537e0ae0ad.tar.gz
rust-dda4709b1cba078ab05a32aa9c9359537e0ae0ad.zip
Error on using `yield` without also using `#[coroutine]` on the closure
And suggest adding the `#[coroutine]` to the closure
-rw-r--r--example/polymorphize_coroutine.rs5
-rw-r--r--example/std_example.rs10
2 files changed, 10 insertions, 5 deletions
diff --git a/example/polymorphize_coroutine.rs b/example/polymorphize_coroutine.rs
index c965b34e13b..407da94c0f0 100644
--- a/example/polymorphize_coroutine.rs
+++ b/example/polymorphize_coroutine.rs
@@ -1,4 +1,4 @@
-#![feature(coroutines, coroutine_trait)]
+#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
 
 use std::ops::Coroutine;
 use std::pin::Pin;
@@ -8,7 +8,8 @@ fn main() {
 }
 
 fn run_coroutine<T>() {
-    let mut coroutine = || {
+    let mut coroutine = #[coroutine]
+    || {
         yield;
         return;
     };
diff --git a/example/std_example.rs b/example/std_example.rs
index 0205de55622..90d4ab721da 100644
--- a/example/std_example.rs
+++ b/example/std_example.rs
@@ -1,6 +1,7 @@
 #![feature(
     core_intrinsics,
     coroutines,
+    stmt_expr_attributes,
     coroutine_trait,
     is_sorted,
     repr_simd,
@@ -123,9 +124,12 @@ fn main() {
         test_simd();
     }
 
-    Box::pin(move |mut _task_context| {
-        yield ();
-    })
+    Box::pin(
+        #[coroutine]
+        move |mut _task_context| {
+            yield ();
+        },
+    )
     .as_mut()
     .resume(0);