diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..aef72dd --- /dev/null +++ b/src/lib.rs @@ -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 SecondTrait for First +where + First: FirstTrait, +{ + type Item2 = First::Extra; +} + +impl ThirdTrait for Second +where + Second: SecondTrait, +{ + type Item3 = T; +} + +impl FourthTrait for Third +where + Third: ThirdTrait, +{ + type Item4 = S; +} + +pub trait Extra { + type Error; +} + +struct ImplShoulExist { + _gen: (D, Req), +} + +impl ImplShoulExist +where + D: FourthTrait, + D::Item4: Extra, + >::Error: Into<()>, +{ + fn access_fn(_: D) { + todo!() + } +} + +impl Extra for ImplShoulExist { + type Error = (); +} + +pub fn broken(ms: MS) +where + MS: FirstTrait, + MS::Item: Into<()>, +{ + // Error: Apparently Balance::new doesn't exist during MIR validation + let _ = ImplShoulExist::::access_fn(ms); +} diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index 4dbc9b2..0000000 --- a/src/main.rs +++ /dev/null @@ -1,73 +0,0 @@ -trait Stream { - type Item; -} - -trait TryStream: Stream { - type TryItem; -} - -impl TryStream for S -where - S: Stream, -{ - type TryItem = T; -} - -trait Discover { - type Service; -} - -impl Discover for D -where - D: TryStream, -{ - type Service = S; -} - -pub trait Service { - type Error; -} - -pub trait MakeService { - type Error; - type Service: Service<(), Error = Self::Error>; -} - -struct Balance { - _dreq: (D, Req), -} - -impl Balance -where - D: Discover, - D::Service: Service, - >::Error: Into<()>, -{ - fn new(_: D) -> Self { - todo!() - } -} - -impl Service for Balance { - type Error = (); -} - -impl Stream for MS -where - MS: MakeService, -{ - type Item = MS::Service; -} - -pub fn broken(ms: MS) -where - MS: MakeService, - MS::Error: Into<()>, -{ - // Error: Apparently Balance::new doesn't exist during MIR validation - let _ = Balance::::new(ms); -} - -fn main() { - println!("Hello, world!"); -}