rust/tests/ui/traits/new-solver/generator.rs
2023-01-26 03:15:36 +00:00

33 lines
614 B
Rust

// compile-flags: -Ztrait-solver=next
// edition: 2021
// revisions: pass fail
//[pass] check-pass
#![feature(generator_trait, generators)]
use std::ops::Generator;
struct A;
struct B;
struct C;
fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {}
#[cfg(fail)]
fn main() {
needs_generator(|| {
//[fail]~^ ERROR Generator<A>` is not satisfied
//[fail]~| ERROR as Generator<A>>::Yield == B`
//[fail]~| ERROR as Generator<A>>::Return == C`
yield ();
});
}
#[cfg(pass)]
fn main() {
needs_generator(|_: A| {
let _: A = yield B;
C
})
}