]> git.lizzy.rs Git - rust.git/blob - src/test/ui/function-pointer/issue-102289.rs
Rollup merge of #105758 - Nilstrieb:typeck-results-mod, r=compiler-errors
[rust.git] / src / test / ui / function-pointer / issue-102289.rs
1 // check-pass
2
3 pub(crate) trait Parser: Sized {
4     type Output;
5     fn parse(&mut self, _input: &str) -> Result<(), ()> {
6         loop {}
7     }
8     fn map<F, B>(self, _f: F) -> Map<Self, F>
9     where
10         F: FnMut(Self::Output) -> B,
11     {
12         todo!()
13     }
14 }
15
16 pub(crate) struct Chainl1<P, Op>(P, Op);
17 impl<P, Op> Parser for Chainl1<P, Op>
18 where
19     P: Parser,
20     Op: Parser,
21     Op::Output: FnOnce(P::Output, P::Output) -> P::Output,
22 {
23     type Output = P::Output;
24 }
25 pub(crate) fn chainl1<P, Op>(_parser: P, _op: Op) -> Chainl1<P, Op>
26 where
27     P: Parser,
28     Op: Parser,
29     Op::Output: FnOnce(P::Output, P::Output) -> P::Output,
30 {
31     loop {}
32 }
33
34 pub(crate) struct Map<P, F>(P, F);
35 impl<A, B, P, F> Parser for Map<P, F>
36 where
37     P: Parser<Output = A>,
38     F: FnMut(A) -> B,
39 {
40     type Output = B;
41 }
42
43 impl Parser for u32 {
44     type Output = ();
45 }
46
47 pub fn chainl1_error_consume() {
48     fn first<T, U>(t: T, _: U) -> T {
49         t
50     }
51     let _ = chainl1(1, 1.map(|_| first)).parse("");
52 }
53
54 fn main() {}