about summary refs log tree commit diff
path: root/tests/ui/async-await/issues/issue-60655-latebound-regions.rs
blob: f9eeb361b1396e49cd2fb588c4318bf61b48d270 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Test that opaque `impl Trait` types are allowed to contain late-bound regions.

//@ check-pass
//@ edition:2018

#![feature(type_alias_impl_trait)]

use std::future::Future;

pub type Func = impl Sized;

// Late bound region should be allowed to escape the function, since it's bound
// in the type.
#[define_opaque(Func)]
fn null_function_ptr() -> Func {
    None::<for<'a> fn(&'a ())>
}

async fn async_nop(_: &u8) {}

pub type ServeFut = impl Future<Output = ()>;

// Late bound regions occur in the coroutine witness type here.
#[define_opaque(ServeFut)]
fn serve() -> ServeFut {
    async move {
        let x = 5;
        async_nop(&x).await
    }
}

fn main() {}