about summary refs log tree commit diff
path: root/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang-2.rs
blob: 4cdf4bf8def6caefb343be9bdaab83285e02316e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//@ edition: 2021
//@ build-fail

// Regression test for <https://github.com/rust-lang/rust/issues/135780>.

use std::future::Future;
use std::ops::AsyncFn;
use std::pin::Pin;

fn recur<'l>(closure: &'l impl AsyncFn()) -> Pin<Box<dyn Future<Output = ()> + 'l>> {
    Box::pin(async move {
        let _ = closure();
        let _ = recur(&async || {
            //~^ ERROR reached the recursion limit
            let _ = closure();
        });
    })
}

fn main() {
    let closure = async || {};
    let _ = recur(&closure);
}