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