about summary refs log tree commit diff
path: root/tests/pretty
diff options
context:
space:
mode:
authorEric Holk <ericholk@microsoft.com>2025-03-12 16:27:52 -0700
committerEric Holk <ericholk@microsoft.com>2025-03-14 12:21:59 -0700
commit1c0916a2b3cd6c595e1c7b69a31d507f7619bb67 (patch)
tree51e37950d5efc1cee3074816313740909128b344 /tests/pretty
parentedf65e735cd871d01149131f5d050293a9f1037c (diff)
downloadrust-1c0916a2b3cd6c595e1c7b69a31d507f7619bb67.tar.gz
rust-1c0916a2b3cd6c595e1c7b69a31d507f7619bb67.zip
Preserve yield position during pretty printing
Diffstat (limited to 'tests/pretty')
-rw-r--r--tests/pretty/postfix-yield.rs15
1 files changed, 15 insertions, 0 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; });
+}