Skip to content

Commit 1443f3b

Browse files
authored
Rollup merge of #60243 - davidtwco:issue-53249, r=cramertj
Add regression test for #53249. Fixes #53249. r? @cramertj
2 parents 3fffcd3 + 04023dc commit 1443f3b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/test/ui/issue-53249.rs

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// compile-pass
2+
// edition:2018
3+
4+
#![feature(arbitrary_self_types, async_await, await_macro)]
5+
6+
use std::task::{self, Poll};
7+
use std::future::Future;
8+
use std::marker::Unpin;
9+
use std::pin::Pin;
10+
11+
// This is a regression test for a ICE/unbounded recursion issue relating to async-await.
12+
13+
#[derive(Debug)]
14+
#[must_use = "futures do nothing unless polled"]
15+
pub struct Lazy<F> {
16+
f: Option<F>
17+
}
18+
19+
impl<F> Unpin for Lazy<F> {}
20+
21+
pub fn lazy<F, R>(f: F) -> Lazy<F>
22+
where F: FnOnce(&mut task::Context) -> R,
23+
{
24+
Lazy { f: Some(f) }
25+
}
26+
27+
impl<R, F> Future for Lazy<F>
28+
where F: FnOnce(&mut task::Context) -> R,
29+
{
30+
type Output = R;
31+
32+
fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context) -> Poll<R> {
33+
Poll::Ready((self.f.take().unwrap())(cx))
34+
}
35+
}
36+
37+
async fn __receive<WantFn, Fut>(want: WantFn) -> ()
38+
where Fut: Future<Output = ()>, WantFn: Fn(&Box<Send + 'static>) -> Fut,
39+
{
40+
await!(lazy(|_| ()));
41+
}
42+
43+
pub fn basic_spawn_receive() {
44+
async { await!(__receive(|_| async { () })) };
45+
}
46+
47+
fn main() {}

0 commit comments

Comments
 (0)