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