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
620 B
Rust
Raw Normal View History

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