2019-03-04 12:53:12 -06:00
|
|
|
// This issue reproduces an ICE on compile (E.g. fails on 2018-12-19 nightly).
|
2023-04-21 19:08:38 -05:00
|
|
|
// "cannot relate bound region: ReLateBound(DebruijnIndex(1), BrAnon(1)) <= '?1"
|
2019-03-04 12:53:12 -06:00
|
|
|
// run-pass
|
|
|
|
// edition:2018
|
2019-03-06 02:45:18 -06:00
|
|
|
#![feature(generators,generator_trait)]
|
|
|
|
use std::ops::Generator;
|
2019-03-04 12:53:12 -06:00
|
|
|
|
2019-03-06 02:45:18 -06:00
|
|
|
fn with<F>(f: F) -> impl Generator<Yield=(), Return=()>
|
|
|
|
where F: Fn() -> ()
|
|
|
|
{
|
|
|
|
move || {
|
2019-03-04 12:53:12 -06:00
|
|
|
loop {
|
|
|
|
match f() {
|
|
|
|
_ => yield,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-06 02:45:18 -06:00
|
|
|
}
|
2019-03-04 12:53:12 -06:00
|
|
|
|
2019-03-06 02:45:18 -06:00
|
|
|
fn main() {
|
|
|
|
let data = &vec![1];
|
2020-07-27 19:00:00 -05:00
|
|
|
|| { //~ WARN unused generator that must be used
|
2019-03-06 02:45:18 -06:00
|
|
|
let _to_pin = with(move || println!("{:p}", data));
|
2019-03-05 03:06:24 -06:00
|
|
|
loop {
|
|
|
|
yield
|
|
|
|
}
|
2019-03-06 02:45:18 -06:00
|
|
|
};
|
2019-03-04 12:53:12 -06:00
|
|
|
}
|