diff options
| author | Eric Holk <ericholk@microsoft.com> | 2025-03-13 14:36:02 -0700 |
|---|---|---|
| committer | Eric Holk <ericholk@microsoft.com> | 2025-03-14 12:21:59 -0700 |
| commit | 635eae2d4fc724cb53a3a45975bc18779a3293b1 (patch) | |
| tree | d09e252392e598d39b17e5454e3d8ef54ae08e31 /src/tools/rustfmt/tests | |
| parent | 1c0916a2b3cd6c595e1c7b69a31d507f7619bb67 (diff) | |
Teach rustfmt to handle postfix yield
Diffstat (limited to 'src/tools/rustfmt/tests')
| -rw-r--r-- | src/tools/rustfmt/tests/source/postfix-yield.rs | 15 | ||||
| -rw-r--r-- | src/tools/rustfmt/tests/target/postfix-yield.rs | 12 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/tools/rustfmt/tests/source/postfix-yield.rs b/src/tools/rustfmt/tests/source/postfix-yield.rs new file mode 100644 index 00000000000..8a8958f3ad4 --- /dev/null +++ b/src/tools/rustfmt/tests/source/postfix-yield.rs @@ -0,0 +1,15 @@ +// This demonstrates a proposed alternate or additional option of having yield in postfix position. +//@ edition: 2024 + +#![feature(gen_blocks, coroutines, coroutine_trait, yield_expr)] + +use std::ops::{Coroutine, CoroutineState}; +use std::pin::pin; + +fn main() { + let mut coro = + pin!(#[coroutine] |_: i32| { let x = 1.yield; + + + (x + 2).yield; }); +} diff --git a/src/tools/rustfmt/tests/target/postfix-yield.rs b/src/tools/rustfmt/tests/target/postfix-yield.rs new file mode 100644 index 00000000000..7e94e1e095a --- /dev/null +++ b/src/tools/rustfmt/tests/target/postfix-yield.rs @@ -0,0 +1,12 @@ +// This demonstrates a proposed alternate or additional option of having yield in postfix position. +//@ edition: 2024 + +#![feature(gen_blocks, coroutines, coroutine_trait, yield_expr)] + +use std::ops::{Coroutine, CoroutineState}; +use std::pin::pin; + +fn main() { + let mut coro = + pin!(#[coroutine] |_: i32| { let x = 1.yield; (x + 2).yield; }); +} |
