]> git.lizzy.rs Git - rust.git/blob - tests/ui/bench/issue-32062.rs
Rollup merge of #107091 - clubby789:infer-ftl-missing-dollar, r=compiler-errors
[rust.git] / tests / ui / bench / issue-32062.rs
1 // run-pass
2
3 // pretty-expanded FIXME #23616
4
5 fn main() {
6     let _ = test(Some(0).into_iter());
7 }
8
9 trait Parser {
10     type Input: Iterator;
11     type Output;
12     fn parse(self, input: Self::Input) -> Result<(Self::Output, Self::Input), ()>;
13     fn chain<P>(self, p: P) -> Chain<Self, P> where Self: Sized {
14         Chain(self, p)
15     }
16 }
17
18 struct Token<T>(#[allow(unused_tuple_struct_fields)] T::Item) where T: Iterator;
19
20 impl<T> Parser for Token<T> where T: Iterator {
21     type Input = T;
22     type Output = T::Item;
23     fn parse(self, _input: Self::Input) -> Result<(Self::Output, Self::Input), ()> {
24         Err(())
25     }
26 }
27
28 struct Chain<L, R>(#[allow(unused_tuple_struct_fields)] L, #[allow(unused_tuple_struct_fields)] R);
29
30 impl<L, R> Parser for Chain<L, R> where L: Parser, R: Parser<Input = L::Input> {
31     type Input = L::Input;
32     type Output = (L::Output, R::Output);
33     fn parse(self, _input: Self::Input) -> Result<(Self::Output, Self::Input), ()> {
34         Err(())
35     }
36 }
37
38 fn test<I>(i: I) -> Result<((), I), ()> where I: Iterator<Item = i32> {
39     Chain(Token(0), Token(1))
40         .chain(Chain(Token(0), Token(1)))
41         .chain(Chain(Token(0), Token(1)))
42         .chain(Chain(Token(0), Token(1)))
43         .chain(Chain(Token(0), Token(1)))
44         .chain(Chain(Token(0), Token(1)))
45         .chain(Chain(Token(0), Token(1)))
46         .chain(Chain(Token(0), Token(1)))
47         .chain(Chain(Token(0), Token(1)))
48         .parse(i)
49         .map(|(_, i)| ((), i))
50 }