Skip to content

Commit cb61113

Browse files
tests
1 parent 9f6b9dd commit cb61113

5 files changed

+159
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// compile-flags: -Znormalize-docs
2+
3+
#![feature(type_alias_impl_trait)]
4+
5+
trait Allocator {
6+
type Buffer;
7+
}
8+
9+
struct DefaultAllocator;
10+
11+
// This unconstrained impl parameter causes the normalization of
12+
// `<DefaultAllocator as Allocator>::Buffer` to be ambiguous,
13+
// which caused an ICE with `-Znormalize-docs`.
14+
impl<T> Allocator for DefaultAllocator {
15+
type Buffer = ();
16+
}
17+
18+
type A = impl Fn(<DefaultAllocator as Allocator>::Buffer);
19+
20+
fn foo() -> A {
21+
|_| ()
22+
}
23+
24+
fn main() {}
+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// edition:2021
2+
3+
mod hyper {
4+
use std::{fmt::Debug, future::Future, marker::PhantomData, pin::Pin, task::Poll};
5+
6+
pub trait HttpBody {
7+
type Error;
8+
}
9+
impl HttpBody for () {
10+
//~^ ERROR not all trait items implemented, missing: `Error`
11+
// don't implement `Error` here for the ICE
12+
}
13+
14+
pub struct Server<I, S>(I, S);
15+
16+
pub fn serve<I, S>(_: S) -> Server<I, S> {
17+
todo!()
18+
}
19+
20+
impl<S, B> Future for Server<(), S>
21+
where
22+
S: MakeServiceRef<(), (), ResBody = B>,
23+
B: HttpBody,
24+
B::Error: Debug,
25+
{
26+
type Output = ();
27+
28+
fn poll(self: Pin<&mut Self>, _: &mut std::task::Context<'_>) -> Poll<Self::Output> {
29+
todo!()
30+
}
31+
}
32+
33+
pub trait MakeServiceRef<Target, ReqBody> {
34+
type ResBody;
35+
}
36+
37+
impl<T, S> MakeServiceRef<(), ()> for T
38+
where
39+
T: for<'a> Service<&'a (), Response = S>,
40+
S: Service<()>,
41+
{
42+
type ResBody = ();
43+
}
44+
45+
pub struct MakeServiceFn<F>(pub F);
46+
pub struct ServiceFn<F, R>(pub PhantomData<(F, R)>);
47+
48+
pub trait Service<Request> {
49+
type Response;
50+
}
51+
52+
impl<'t, F, Ret, Target, Svc> Service<&'t Target> for MakeServiceFn<F>
53+
where
54+
F: Fn() -> Ret,
55+
Ret: Future<Output = Result<Svc, ()>>,
56+
{
57+
type Response = Svc;
58+
}
59+
60+
impl<F, ReqBody, Ret, ResBody, E> Service<ReqBody> for ServiceFn<F, ReqBody>
61+
where
62+
F: Fn() -> Ret,
63+
Ret: Future<Output = Result<ResBody, E>>,
64+
{
65+
type Response = ResBody;
66+
}
67+
}
68+
69+
async fn smarvice() -> Result<(), ()> {
70+
Ok(())
71+
}
72+
73+
fn service_fn<F, R, S>(f: F) -> hyper::ServiceFn<F, R>
74+
where
75+
F: Fn() -> S,
76+
{
77+
hyper::ServiceFn(std::marker::PhantomData)
78+
}
79+
80+
async fn iceice() {
81+
let service = hyper::MakeServiceFn(|| async { Ok::<_, ()>(service_fn(|| smarvice())) });
82+
hyper::serve::<(), _>(service).await;
83+
}
84+
85+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0046]: not all trait items implemented, missing: `Error`
2+
--> $DIR/issue-103181-1.rs:9:5
3+
|
4+
LL | type Error;
5+
| ---------- `Error` from trait
6+
LL | }
7+
LL | impl HttpBody for () {
8+
| ^^^^^^^^^^^^^^^^^^^^ missing `Error` in implementation
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0046`.
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// edition:2021
2+
3+
trait SendFuture: Send {
4+
type Output;
5+
}
6+
7+
impl<Fut: Send> SendFuture for Fut {
8+
type Output = ();
9+
}
10+
11+
async fn broken_fut() {
12+
ident_error;
13+
//~^ ERROR cannot find value `ident_error` in this scope
14+
}
15+
16+
// triggers normalization of `<Fut as SendFuture>::Output`,
17+
// which requires `Fut: Send`.
18+
fn normalize<Fut: SendFuture>(_: Fut, _: Fut::Output) {}
19+
20+
async fn iceice<A, B>()
21+
// <- async fn is necessary
22+
where
23+
A: Send,
24+
B: Send, // <- a second bound
25+
{
26+
normalize(broken_fut(), ());
27+
}
28+
29+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0425]: cannot find value `ident_error` in this scope
2+
--> $DIR/issue-103181-2.rs:12:5
3+
|
4+
LL | ident_error;
5+
| ^^^^^^^^^^^ not found in this scope
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0425`.

0 commit comments

Comments
 (0)