// check-pass #![allow(dead_code)] trait ParseError { type StreamError; } impl ParseError for T { type StreamError = (); } trait Stream { type Item; type Error: ParseError; } trait Parser where ::PartialState: Default, { type PartialState; fn parse_mode(_: &Self, _: Self::PartialState) { loop {} } } impl Stream for () { type Item = (); type Error = (); } impl Parser for () { type PartialState = (); } struct AndThen(core::marker::PhantomData<(A, B)>); impl Parser for AndThen where A: Stream, B: Into<::StreamError>, { type PartialState = (); } fn expr() -> impl Parser where A: Stream::Item>, { AndThen::(core::marker::PhantomData) } fn parse_mode_impl() where ::Error: ParseError, A: Stream::Item>, { Parser::parse_mode(&expr::(), Default::default()) } fn main() {}