Skip to content

Commit 94ffb29

Browse files
authored
Rollup merge of #95102 - compiler-errors:issue-94034-bug, r=jackh726
Add known-bug for #95034 Couldn't fix the issue, since I am no type theorist and inference variables in universes above U0 scare me. But I at least wanted to add a known-bug test for it. cc #95034 (does not fix)
2 parents dc1f829 + d5a32d8 commit 94ffb29

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

src/test/ui/hrtb/issue-94034.rs

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// known-bug
2+
// failure-status: 101
3+
// compile-flags: --edition=2021 --crate-type=lib
4+
// rustc-env:RUST_BACKTRACE=0
5+
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" -> ""
17+
18+
// This should not ICE.
19+
20+
use std::{
21+
future::Future,
22+
marker::PhantomData,
23+
pin::Pin,
24+
task::{Context, Poll},
25+
};
26+
27+
mod object {
28+
use super::*;
29+
30+
pub trait Object<'a> {
31+
type Error;
32+
type Future: Future<Output = Self>;
33+
fn create() -> Self::Future;
34+
}
35+
36+
impl<'a> Object<'a> for u8 {
37+
type Error = ();
38+
type Future = Pin<Box<dyn Future<Output = Self>>>;
39+
fn create() -> Self::Future {
40+
unimplemented!()
41+
}
42+
}
43+
44+
impl<'a, E, A: Object<'a, Error = E>> Object<'a> for (A,) {
45+
type Error = ();
46+
type Future = CustomFut<'a, E, A>;
47+
fn create() -> Self::Future {
48+
unimplemented!()
49+
}
50+
}
51+
52+
pub struct CustomFut<'f, E, A: Object<'f, Error = E>> {
53+
ph: PhantomData<(A::Future,)>,
54+
}
55+
56+
impl<'f, E, A: Object<'f, Error = E>> Future for CustomFut<'f, E, A> {
57+
type Output = (A,);
58+
fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
59+
unimplemented!()
60+
}
61+
}
62+
}
63+
64+
mod async_fn {
65+
use super::*;
66+
67+
pub trait AsyncFn {
68+
type Future: Future<Output = ()>;
69+
fn call(&self) -> Self::Future;
70+
}
71+
72+
impl<F, Fut> AsyncFn for F
73+
where
74+
F: Fn() -> Fut,
75+
Fut: Future<Output = ()>,
76+
{
77+
type Future = Fut;
78+
fn call(&self) -> Self::Future {
79+
(self)()
80+
}
81+
}
82+
}
83+
84+
pub async fn test() {
85+
use self::{async_fn::AsyncFn, object::Object};
86+
87+
async fn create<T: Object<'static>>() {
88+
T::create().await;
89+
}
90+
91+
async fn call_async_fn(inner: impl AsyncFn) {
92+
inner.call().await;
93+
}
94+
95+
call_async_fn(create::<(u8,)>).await;
96+
}

src/test/ui/hrtb/issue-94034.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
thread 'rustc' panicked

0 commit comments

Comments
 (0)