Files
rust/tests/mir-opt/building/coroutine.rs

30 lines
816 B
Rust
Raw Normal View History

2025-09-14 19:08:16 +00:00
// skip-filecheck
//@ edition:2024
//@ compile-flags: -Zmir-opt-level=0 -C panic=abort
#![feature(stmt_expr_attributes)]
#![feature(closure_track_caller)]
#![feature(coroutine_trait)]
#![feature(coroutines)]
use std::ops::{Coroutine, CoroutineState};
use std::panic::Location;
2025-09-14 15:15:49 +00:00
use std::pin::Pin;
2025-09-14 19:08:16 +00:00
// EMIT_MIR coroutine.main-{closure#0}.StateTransform.after.mir
// EMIT_MIR coroutine.main-{closure#1}.StateTransform.after.mir
fn main() {
2025-09-14 15:15:49 +00:00
let simple = #[coroutine]
|arg: String| {
2025-09-14 19:08:16 +00:00
yield ("first", arg.clone(), Location::caller());
yield ("second", arg.clone(), Location::caller());
};
2025-09-14 15:15:49 +00:00
let track_caller = #[track_caller]
#[coroutine]
|arg: String| {
2025-09-14 19:08:16 +00:00
yield ("first", arg.clone(), Location::caller());
yield ("second", arg.clone(), Location::caller());
};
}