2019-06-15 04:08:41 -05:00
|
|
|
// Test that we don't consider temporaries for statement expressions as live
|
|
|
|
// across yields
|
|
|
|
|
|
|
|
//@ check-pass
|
|
|
|
//@ edition:2018
|
|
|
|
|
2024-04-11 08:15:34 -05:00
|
|
|
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
|
2019-06-15 04:08:41 -05:00
|
|
|
|
2023-10-19 11:06:43 -05:00
|
|
|
use std::ops::Coroutine;
|
2019-06-15 04:08:41 -05:00
|
|
|
|
|
|
|
async fn drop_and_await() {
|
|
|
|
async {};
|
|
|
|
async {}.await;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn drop_and_yield() {
|
2024-04-11 08:15:34 -05:00
|
|
|
let x = #[coroutine]
|
|
|
|
|| {
|
2019-06-15 04:08:41 -05:00
|
|
|
String::new();
|
|
|
|
yield;
|
|
|
|
};
|
2020-01-25 13:03:10 -06:00
|
|
|
Box::pin(x).as_mut().resume(());
|
2024-04-11 08:15:34 -05:00
|
|
|
let y = #[coroutine]
|
|
|
|
static || {
|
2019-06-15 04:08:41 -05:00
|
|
|
String::new();
|
|
|
|
yield;
|
|
|
|
};
|
2020-01-25 13:03:10 -06:00
|
|
|
Box::pin(y).as_mut().resume(());
|
2019-06-15 04:08:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
drop_and_await();
|
|
|
|
drop_and_yield();
|
|
|
|
}
|