mirror of
https://github.com/rust-lang/rust.git
synced 2025-09-28 13:46:03 +00:00
30 lines
816 B
Rust
30 lines
816 B
Rust
// 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;
|
|
use std::pin::Pin;
|
|
|
|
// EMIT_MIR coroutine.main-{closure#0}.StateTransform.after.mir
|
|
// EMIT_MIR coroutine.main-{closure#1}.StateTransform.after.mir
|
|
fn main() {
|
|
let simple = #[coroutine]
|
|
|arg: String| {
|
|
yield ("first", arg.clone(), Location::caller());
|
|
yield ("second", arg.clone(), Location::caller());
|
|
};
|
|
|
|
let track_caller = #[track_caller]
|
|
#[coroutine]
|
|
|arg: String| {
|
|
yield ("first", arg.clone(), Location::caller());
|
|
yield ("second", arg.clone(), Location::caller());
|
|
};
|
|
}
|