3 // compile-flags: --edition=2021 --crate-type=lib
4 // rustc-env:RUST_BACKTRACE=0
6 // normalize-stderr-test "thread 'rustc' panicked.*" -> "thread 'rustc' panicked"
7 // normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
8 // normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> ""
9 // normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> ""
10 // normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> ""
11 // normalize-stderr-test "note: compiler flags.*\n\n" -> ""
12 // normalize-stderr-test "note: rustc.*running on.*\n\n" -> ""
13 // normalize-stderr-test "query stack during panic:\n" -> ""
14 // normalize-stderr-test "we're just showing a limited slice of the query stack\n" -> ""
15 // normalize-stderr-test "end of query stack\n" -> ""
16 // normalize-stderr-test "#.*\n" -> ""
18 // This should not ICE.
20 // Refer to the issue for more minimized versions.
26 task::{Context, Poll},
32 pub trait Object<'a> {
34 type Future: Future<Output = Self>;
35 fn create() -> Self::Future;
38 impl<'a> Object<'a> for u8 {
40 type Future = Pin<Box<dyn Future<Output = Self>>>;
41 fn create() -> Self::Future {
46 impl<'a, E, A: Object<'a, Error = E>> Object<'a> for (A,) {
48 type Future = CustomFut<'a, E, A>;
49 fn create() -> Self::Future {
54 pub struct CustomFut<'f, E, A: Object<'f, Error = E>> {
55 ph: PhantomData<(A::Future,)>,
58 impl<'f, E, A: Object<'f, Error = E>> Future for CustomFut<'f, E, A> {
60 fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
70 type Future: Future<Output = ()>;
71 fn call(&self) -> Self::Future;
74 impl<F, Fut> AsyncFn for F
77 Fut: Future<Output = ()>,
80 fn call(&self) -> Self::Future {
87 use self::{async_fn::AsyncFn, object::Object};
89 async fn create<T: Object<'static>>() {
93 async fn call_async_fn(inner: impl AsyncFn) {
97 call_async_fn(create::<(u8,)>).await;