summaryrefslogtreecommitdiffstats
path: root/src/test/ui/function-pointer/issue-102289.rs
blob: de394ca9ad6d41c06f8e940175bec6425e9fd587 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// check-pass

pub(crate) trait Parser: Sized {
    type Output;
    fn parse(&mut self, _input: &str) -> Result<(), ()> {
        loop {}
    }
    fn map<F, B>(self, _f: F) -> Map<Self, F>
    where
        F: FnMut(Self::Output) -> B,
    {
        todo!()
    }
}

pub(crate) struct Chainl1<P, Op>(P, Op);
impl<P, Op> Parser for Chainl1<P, Op>
where
    P: Parser,
    Op: Parser,
    Op::Output: FnOnce(P::Output, P::Output) -> P::Output,
{
    type Output = P::Output;
}
pub(crate) fn chainl1<P, Op>(_parser: P, _op: Op) -> Chainl1<P, Op>
where
    P: Parser,
    Op: Parser,
    Op::Output: FnOnce(P::Output, P::Output) -> P::Output,
{
    loop {}
}

pub(crate) struct Map<P, F>(P, F);
impl<A, B, P, F> Parser for Map<P, F>
where
    P: Parser<Output = A>,
    F: FnMut(A) -> B,
{
    type Output = B;
}

impl Parser for u32 {
    type Output = ();
}

pub fn chainl1_error_consume() {
    fn first<T, U>(t: T, _: U) -> T {
        t
    }
    let _ = chainl1(1, 1.map(|_| first)).parse("");
}

fn main() {}