2019-07-31 23:41:54 +00:00
|
|
|
// Test that opaque `impl Trait` types are allowed to contain late-bound regions.
|
2019-05-13 20:57:20 +00:00
|
|
|
|
2020-04-20 00:27:28 +00:00
|
|
|
// check-pass
|
2019-05-13 20:57:20 +00:00
|
|
|
// edition:2018
|
|
|
|
|
2021-07-26 20:01:16 +00:00
|
|
|
#![feature(type_alias_impl_trait)]
|
2019-05-13 20:57:20 +00:00
|
|
|
|
|
|
|
use std::future::Future;
|
|
|
|
|
2019-07-29 23:11:58 +00:00
|
|
|
pub type Func = impl Sized;
|
2019-05-13 20:57:20 +00:00
|
|
|
|
|
|
|
// Late bound region should be allowed to escape the function, since it's bound
|
|
|
|
// in the type.
|
|
|
|
fn null_function_ptr() -> Func {
|
|
|
|
None::<for<'a> fn(&'a ())>
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn async_nop(_: &u8) {}
|
|
|
|
|
2019-07-29 23:11:58 +00:00
|
|
|
pub type ServeFut = impl Future<Output=()>;
|
2019-05-13 20:57:20 +00:00
|
|
|
|
|
|
|
// Late bound regions occur in the generator witness type here.
|
|
|
|
fn serve() -> ServeFut {
|
|
|
|
async move {
|
|
|
|
let x = 5;
|
|
|
|
async_nop(&x).await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|