]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-83190.rs
Merge commit '97e504549371d7640cf011d266e3c17394fdddac' into sync_cg_clif-2021-12-20
[rust.git] / src / test / ui / issues / issue-83190.rs
1 // check-pass
2
3 // Regression test for issue #83190, triggering an ICE in borrowck.
4
5 pub trait Any {}
6 impl<T> Any for T {}
7
8 pub trait StreamOnce {
9     type Range;
10 }
11
12 pub trait Parser<Input>: Sized {
13     type Output;
14     type PartialState;
15     fn map(self) -> Map<Self> {
16         todo!()
17     }
18 }
19
20 pub struct Map<P>(P);
21 impl<I, P: Parser<I, Output = ()>> Parser<I> for Map<P> {
22     type Output = ();
23     type PartialState = P::PartialState;
24 }
25
26 struct TakeWhile1<Input>(Input);
27 impl<I: StreamOnce> Parser<I> for TakeWhile1<I> {
28     type Output = I::Range;
29     type PartialState = ();
30 }
31 impl<I> TakeWhile1<I> {
32     fn new() -> Self {
33         todo!()
34     }
35 }
36
37 impl<I, A: Parser<I>> Parser<I> for (A,) {
38     type Output = ();
39     type PartialState = Map<A::Output>;
40 }
41
42 pub fn metric_stream_parser<'a, I>() -> impl Parser<I, Output = (), PartialState = impl Any + 'a>
43 where
44     I: StreamOnce<Range = &'a [()]>,
45 {
46     (TakeWhile1::new(),).map()
47 }
48
49 fn main() {}