2019-03-04 12:53:12 -06:00
|
|
|
// This issue reproduces an ICE on compile (E.g. fails on 2018-12-19 nightly).
|
2023-11-13 08:00:05 -06:00
|
|
|
// "cannot relate bound region: ReBound(DebruijnIndex(1), BrAnon(1)) <= '?1"
|
2019-03-04 12:53:12 -06:00
|
|
|
// run-pass
|
|
|
|
// edition:2018
|
2023-10-19 16:46:28 -05:00
|
|
|
#![feature(coroutines,coroutine_trait)]
|
2023-10-19 11:06:43 -05:00
|
|
|
use std::ops::Coroutine;
|
2019-03-04 12:53:12 -06:00
|
|
|
|
2023-10-19 11:06:43 -05:00
|
|
|
fn with<F>(f: F) -> impl Coroutine<Yield=(), Return=()>
|
2019-03-06 02:45:18 -06:00
|
|
|
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];
|
2023-10-19 16:46:28 -05:00
|
|
|
|| { //~ WARN unused coroutine 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
|
|
|
}
|