blob: 30788e3c1864bb1935c4ae4a1ee029b74c6e56a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#![feature(generator_trait)]
#![feature(generators)]
// Test that we cannot create a generator that returns a value of its
// own type.
use std::ops::Generator;
pub fn want_cyclic_generator_return<T>(_: T)
where T: Generator<Yield = (), Return = T>
{
}
fn supply_cyclic_generator_return() {
want_cyclic_generator_return(|| {
//~^ ERROR type mismatch
if false { yield None.unwrap(); }
None.unwrap()
})
}
pub fn want_cyclic_generator_yield<T>(_: T)
where T: Generator<Yield = T, Return = ()>
{
}
fn supply_cyclic_generator_yield() {
want_cyclic_generator_yield(|| {
//~^ ERROR type mismatch
if false { yield None.unwrap(); }
None.unwrap()
})
}
fn main() { }
|