rust/tests/mir-opt/inline_coroutine_body.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
821 B
Rust
Raw Permalink Normal View History

2024-03-07 19:34:05 -06:00
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// skip-filecheck
//@ test-mir-pass: Inline
2024-03-07 19:34:05 -06:00
//@ edition: 2021
//@ compile-flags: -Zinline-mir-hint-threshold=10000 -Zinline-mir-threshold=10000 --crate-type=lib
pub async fn run(permit: ActionPermit<'_, ()>, ctx: &mut core::task::Context<'_>) {
run2(permit, ctx);
}
// EMIT_MIR inline_coroutine_body.run2-{closure#0}.Inline.diff
2024-03-07 19:34:05 -06:00
fn run2<T>(permit: ActionPermit<'_, T>, ctx: &mut core::task::Context) {
_ = || {
let mut fut = ActionPermit::perform(permit);
let fut = unsafe { core::pin::Pin::new_unchecked(&mut fut) };
_ = core::future::Future::poll(fut, ctx);
};
}
pub struct ActionPermit<'a, T> {
_guard: core::cell::Ref<'a, T>,
}
impl<'a, T> ActionPermit<'a, T> {
async fn perform(self) {
core::future::ready(()).await
}
}