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

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

37 lines
597 B
Rust
Raw Normal View History

2023-12-14 06:11:28 -06:00
//@ compile-flags: -Znext-solver
2023-01-24 17:38:20 -06:00
//@ 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() {
needs_coroutine(
#[coroutine]
|| {
//[fail]~^ ERROR Coroutine<A>` is not satisfied
yield ();
},
);
2023-01-24 17:38:20 -06:00
}
#[cfg(pass)]
fn main() {
needs_coroutine(
#[coroutine]
|_: A| {
let _: A = yield B;
C
},
)
2023-01-24 17:38:20 -06:00
}