mirror of
https://github.com/Noratrieb/101844-repro.git
synced 2026-01-17 07:25:02 +01:00
pretty small
This commit is contained in:
parent
44271dcd7b
commit
5b384039db
2 changed files with 69 additions and 73 deletions
69
src/lib.rs
Normal file
69
src/lib.rs
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
trait SecondTrait {
|
||||||
|
type Item2;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait FirstTrait {
|
||||||
|
type Item;
|
||||||
|
type Extra: Extra<(), Error = Self::Item>;
|
||||||
|
}
|
||||||
|
|
||||||
|
trait ThirdTrait: SecondTrait {
|
||||||
|
type Item3;
|
||||||
|
}
|
||||||
|
|
||||||
|
trait FourthTrait {
|
||||||
|
type Item4;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<First> SecondTrait for First
|
||||||
|
where
|
||||||
|
First: FirstTrait,
|
||||||
|
{
|
||||||
|
type Item2 = First::Extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<Second, T> ThirdTrait for Second
|
||||||
|
where
|
||||||
|
Second: SecondTrait<Item2 = T>,
|
||||||
|
{
|
||||||
|
type Item3 = T;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<S, Third: ?Sized> FourthTrait for Third
|
||||||
|
where
|
||||||
|
Third: ThirdTrait<Item3 = S>,
|
||||||
|
{
|
||||||
|
type Item4 = S;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait Extra<Request> {
|
||||||
|
type Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ImplShoulExist<D, Req> {
|
||||||
|
_gen: (D, Req),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<D, Req> ImplShoulExist<D, Req>
|
||||||
|
where
|
||||||
|
D: FourthTrait,
|
||||||
|
D::Item4: Extra<Req>,
|
||||||
|
<D::Item4 as Extra<Req>>::Error: Into<()>,
|
||||||
|
{
|
||||||
|
fn access_fn(_: D) {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<D, Req> Extra<Req> for ImplShoulExist<D, Req> {
|
||||||
|
type Error = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn broken<MS>(ms: MS)
|
||||||
|
where
|
||||||
|
MS: FirstTrait,
|
||||||
|
MS::Item: Into<()>,
|
||||||
|
{
|
||||||
|
// Error: Apparently Balance::new doesn't exist during MIR validation
|
||||||
|
let _ = ImplShoulExist::<MS, ()>::access_fn(ms);
|
||||||
|
}
|
||||||
73
src/main.rs
73
src/main.rs
|
|
@ -1,73 +0,0 @@
|
||||||
trait Stream {
|
|
||||||
type Item;
|
|
||||||
}
|
|
||||||
|
|
||||||
trait TryStream: Stream {
|
|
||||||
type TryItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S, T> TryStream for S
|
|
||||||
where
|
|
||||||
S: Stream<Item = T>,
|
|
||||||
{
|
|
||||||
type TryItem = T;
|
|
||||||
}
|
|
||||||
|
|
||||||
trait Discover {
|
|
||||||
type Service;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S, D: ?Sized> Discover for D
|
|
||||||
where
|
|
||||||
D: TryStream<TryItem = S>,
|
|
||||||
{
|
|
||||||
type Service = S;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Service<Request> {
|
|
||||||
type Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait MakeService {
|
|
||||||
type Error;
|
|
||||||
type Service: Service<(), Error = Self::Error>;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Balance<D, Req> {
|
|
||||||
_dreq: (D, Req),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D, Req> Balance<D, Req>
|
|
||||||
where
|
|
||||||
D: Discover,
|
|
||||||
D::Service: Service<Req>,
|
|
||||||
<D::Service as Service<Req>>::Error: Into<()>,
|
|
||||||
{
|
|
||||||
fn new(_: D) -> Self {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D, Req> Service<Req> for Balance<D, Req> {
|
|
||||||
type Error = ();
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<MS> Stream for MS
|
|
||||||
where
|
|
||||||
MS: MakeService,
|
|
||||||
{
|
|
||||||
type Item = MS::Service;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn broken<MS>(ms: MS)
|
|
||||||
where
|
|
||||||
MS: MakeService,
|
|
||||||
MS::Error: Into<()>,
|
|
||||||
{
|
|
||||||
// Error: Apparently Balance::new doesn't exist during MIR validation
|
|
||||||
let _ = Balance::<MS, ()>::new(ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue