rust/tests/ui/traits/new-solver/coroutine.rs

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

33 lines
614 B
Rust
Raw Normal View History

2023-01-24 17:38:20 -06:00
// compile-flags: -Ztrait-solver=next
// edition: 2021
// revisions: pass fail
//[pass] check-pass
2023-10-19 16:46:28 -05:00
#![feature(coroutine_trait, coroutines)]
2023-01-24 17:38:20 -06:00
2023-10-19 11:06:43 -05:00
use std::ops::Coroutine;
2023-01-24 17:38:20 -06:00
struct A;
struct B;
struct C;
2023-10-19 16:46:28 -05:00
fn needs_coroutine(_: impl Coroutine<A, Yield = B, Return = C>) {}
2023-01-24 17:38:20 -06:00
#[cfg(fail)]
fn main() {
2023-10-19 16:46:28 -05:00
needs_coroutine(|| {
2023-10-19 11:06:43 -05:00
//[fail]~^ ERROR Coroutine<A>` is not satisfied
//[fail]~| ERROR as Coroutine<A>>::Yield == B`
//[fail]~| ERROR as Coroutine<A>>::Return == C`
2023-01-24 17:38:20 -06:00
yield ();
});
}
#[cfg(pass)]
fn main() {
2023-10-19 16:46:28 -05:00
needs_coroutine(|_: A| {
2023-01-24 17:38:20 -06:00
let _: A = yield B;
C
})
}