about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/pretty/postfix-yield.rs15
-rw-r--r--tests/ui/coroutine/postfix-yield.rs6
2 files changed, 18 insertions, 3 deletions
diff --git a/tests/pretty/postfix-yield.rs b/tests/pretty/postfix-yield.rs
new file mode 100644
index 00000000000..f76e8142ae8
--- /dev/null
+++ b/tests/pretty/postfix-yield.rs
@@ -0,0 +1,15 @@
+// This demonstrates a proposed alternate or additional option of having yield in postfix position.
+//@ edition: 2024
+//@ pp-exact
+
+#![feature(gen_blocks, coroutines, coroutine_trait, yield_expr)]
+
+use std::ops::{Coroutine, CoroutineState};
+use std::pin::pin;
+
+fn main() {
+    let mut gn = gen { yield 1; 2.yield; (1 + 2).yield; };
+
+    let mut coro =
+        pin!(#[coroutine] |_: i32| { let x = 1.yield; (x + 2).yield; });
+}
diff --git a/tests/ui/coroutine/postfix-yield.rs b/tests/ui/coroutine/postfix-yield.rs
index 77b1c2a19d0..ff843138c8c 100644
--- a/tests/ui/coroutine/postfix-yield.rs
+++ b/tests/ui/coroutine/postfix-yield.rs
@@ -9,7 +9,7 @@ use std::ops::{Coroutine, CoroutineState};
 use std::pin::pin;
 
 fn main() {
-    // generators (i.e. yield doesn't return anything useful) 
+    // generators (i.e. yield doesn't return anything useful)
     let mut gn = gen {
         yield 1;
         2.yield;
@@ -23,8 +23,8 @@ fn main() {
     let mut coro = pin!(
         #[coroutine]
         |_: i32| {
-            let x = yield 1;
-            yield x + 2;
+            let x = 1.yield;
+            (x + 2).yield;
         }
     );