rust/tests/ui/traits/new-solver/generator.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
#![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
})
}