]> git.lizzy.rs Git - rust.git/blob - tests/ui/associated-types/issue-67684.rs
Rollup merge of #107519 - joboet:raw_os_error_ty, r=Amanieu
[rust.git] / tests / ui / associated-types / issue-67684.rs
1 // check-pass
2
3 #![allow(dead_code)]
4
5 trait ParseError {
6     type StreamError;
7 }
8
9 impl<T> ParseError for T {
10     type StreamError = ();
11 }
12
13 trait Stream {
14     type Item;
15     type Error: ParseError;
16 }
17
18 trait Parser
19 where
20     <Self as Parser>::PartialState: Default,
21 {
22     type PartialState;
23     fn parse_mode(_: &Self, _: Self::PartialState) {
24         loop {}
25     }
26 }
27
28 impl Stream for () {
29     type Item = ();
30     type Error = ();
31 }
32
33 impl Parser for () {
34     type PartialState = ();
35 }
36
37 struct AndThen<A, B>(core::marker::PhantomData<(A, B)>);
38
39 impl<A, B> Parser for AndThen<A, B>
40 where
41     A: Stream,
42     B: Into<<A::Error as ParseError>::StreamError>,
43 {
44     type PartialState = ();
45 }
46
47 fn expr<A>() -> impl Parser
48 where
49     A: Stream<Error = <A as Stream>::Item>,
50 {
51     AndThen::<A, ()>(core::marker::PhantomData)
52 }
53
54 fn parse_mode_impl<A>()
55 where
56     <A as Stream>::Error: ParseError,
57     A: Stream<Error = <A as Stream>::Item>,
58 {
59     Parser::parse_mode(&expr::<A>(), Default::default())
60 }
61
62 fn main() {}