Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit 5cb099f

Browse files
authored
Merge pull request #1176 from matthiaskrgr/mar21
add 4 ices
2 parents d60e25b + e3da5ef commit 5cb099f

File tree

4 files changed

+117
-0
lines changed

4 files changed

+117
-0
lines changed

ices/95034.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
rustc --crate-type lib --edition=2021 - 2>&1 << EOF
2+
3+
use std::{
4+
future::Future,
5+
marker::PhantomData,
6+
pin::Pin,
7+
task::{Context, Poll},
8+
};
9+
10+
mod object {
11+
use super::*;
12+
13+
pub trait Object<'a> {
14+
type Error;
15+
type Future: Future<Output = Self>;
16+
fn create() -> Self::Future;
17+
}
18+
19+
impl<'a> Object<'a> for u8 {
20+
type Error = ();
21+
type Future = Pin<Box<dyn Future<Output = Self>>>;
22+
fn create() -> Self::Future {
23+
unimplemented!()
24+
}
25+
}
26+
27+
impl<'a, E, A: Object<'a, Error = E>> Object<'a> for (A,) {
28+
type Error = ();
29+
type Future = CustomFut<'a, E, A>;
30+
fn create() -> Self::Future {
31+
unimplemented!()
32+
}
33+
}
34+
35+
pub struct CustomFut<'f, E, A: Object<'f, Error = E>> {
36+
ph: PhantomData<(A::Future,)>,
37+
}
38+
39+
impl<'f, E, A: Object<'f, Error = E>> Future for CustomFut<'f, E, A> {
40+
type Output = (A,);
41+
fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
42+
unimplemented!()
43+
}
44+
}
45+
}
46+
47+
mod async_fn {
48+
use super::*;
49+
50+
pub trait AsyncFn {
51+
type Future: Future<Output = ()>;
52+
fn call(&self) -> Self::Future;
53+
}
54+
55+
impl<F, Fut> AsyncFn for F
56+
where
57+
F: Fn() -> Fut,
58+
Fut: Future<Output = ()>,
59+
{
60+
type Future = Fut;
61+
fn call(&self) -> Self::Future {
62+
(self)()
63+
}
64+
}
65+
}
66+
67+
pub async fn test() {
68+
use self::{async_fn::AsyncFn, object::Object};
69+
70+
async fn create<T: Object<'static>>() {
71+
T::create().await;
72+
}
73+
74+
async fn call_async_fn(inner: impl AsyncFn) {
75+
inner.call().await;
76+
}
77+
78+
call_async_fn(create::<(u8,)>).await;
79+
}
80+
81+
EOF

ices/95134.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
rustc --edition=2021 - 2>&1 << EOF
2+
3+
pub fn encode_num<Writer: ExampleWriter>(n: u32, mut writer: Writer) -> Result<(), Writer::Error> {
4+
if n > 15 {
5+
encode_num(n / 16, &mut writer)?;
6+
}
7+
Ok(())
8+
}
9+
10+
pub trait ExampleWriter {
11+
type Error;
12+
}
13+
14+
impl<'a, T: ExampleWriter> ExampleWriter for &'a mut T {
15+
type Error = T::Error;
16+
}
17+
18+
struct EmptyWriter;
19+
20+
impl ExampleWriter for EmptyWriter {
21+
type Error = ();
22+
}
23+
24+
fn main() {
25+
encode_num(69, &mut EmptyWriter).unwrap();
26+
}
27+
28+
EOF

ices/95151.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#[track_caller]
2+
macro_rules! _foo {
3+
() => {};
4+
}
5+
6+
fn main() {
7+
}

ices/95163.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn bar() -> impl Into<<() as Reexported;

0 commit comments

Comments
 (0)