diff options
Diffstat (limited to 'tests/ui/coroutine/yield-in-initializer.rs')
-rw-r--r-- | tests/ui/coroutine/yield-in-initializer.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/ui/coroutine/yield-in-initializer.rs b/tests/ui/coroutine/yield-in-initializer.rs new file mode 100644 index 000000000..5a7b3a4fe --- /dev/null +++ b/tests/ui/coroutine/yield-in-initializer.rs @@ -0,0 +1,17 @@ +// run-pass + +#![feature(coroutines)] + +fn main() { + static || { //~ WARN unused coroutine that must be used + loop { + // Test that `opt` is not live across the yield, even when borrowed in a loop + // See https://github.com/rust-lang/rust/issues/52792 + let opt = { + yield; + true + }; + let _ = &opt; + } + }; +} |