]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generator/issue-61442-stmt-expr-with-drop.rs
Auto merge of #102655 - joboet:windows_tls_opt, r=ChrisDenton
[rust.git] / src / test / ui / generator / issue-61442-stmt-expr-with-drop.rs
1 // Test that we don't consider temporaries for statement expressions as live
2 // across yields
3
4 // check-pass
5 // edition:2018
6
7 #![feature(generators, generator_trait)]
8
9 use std::ops::Generator;
10
11 async fn drop_and_await() {
12     async {};
13     async {}.await;
14 }
15
16 fn drop_and_yield() {
17     let x = || {
18         String::new();
19         yield;
20     };
21     Box::pin(x).as_mut().resume(());
22     let y = static || {
23         String::new();
24         yield;
25     };
26     Box::pin(y).as_mut().resume(());
27 }
28
29 fn main() {
30     drop_and_await();
31     drop_and_yield();
32 }