rust/tests/ui/impl-trait/recursive-coroutine.rs

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

23 lines
566 B
Rust
Raw Normal View History

2023-10-19 21:46:28 +00:00
#![feature(coroutines, coroutine_trait)]
2023-10-19 16:06:43 +00:00
use std::ops::{Coroutine, CoroutineState};
2023-10-19 16:06:43 +00:00
fn foo() -> impl Coroutine<Yield = (), Return = ()> {
//~^ ERROR cannot resolve opaque type
//~| NOTE recursive opaque type
//~| NOTE in this expansion of desugaring of
|| {
let mut gen = Box::pin(foo());
2023-10-19 21:46:28 +00:00
//~^ NOTE coroutine captures itself here
let mut r = gen.as_mut().resume(());
2023-10-19 16:06:43 +00:00
while let CoroutineState::Yielded(v) = r {
yield v;
r = gen.as_mut().resume(());
}
}
}
fn main() {
foo();
}