]> git.lizzy.rs Git - rust.git/blob - src/test/ui/iterators/iter-map-fold-type-length.rs
move an `assert!` to the right place
[rust.git] / src / test / ui / iterators / iter-map-fold-type-length.rs
1 // run-pass
2 //! Check that type lengths don't explode with `Map` folds.
3 //!
4 //! The normal limit is a million, and this test used to exceed 1.5 million, but
5 //! now we can survive an even tighter limit. Still seems excessive though...
6 #![type_length_limit = "256000"]
7
8 // Custom wrapper so Iterator methods aren't specialized.
9 struct Iter<I>(I);
10
11 impl<I> Iterator for Iter<I>
12 where
13     I: Iterator
14 {
15     type Item = I::Item;
16
17     fn next(&mut self) -> Option<Self::Item> {
18         self.0.next()
19     }
20 }
21
22 fn main() {
23     let c = Iter(0i32..10)
24         .map(|x| x)
25         .map(|x| x)
26         .map(|x| x)
27         .map(|x| x)
28         .map(|x| x)
29         .map(|x| x)
30         .map(|x| x)
31         .map(|x| x)
32         .map(|x| x)
33         .map(|x| x)
34         .map(|x| x)
35         .map(|x| x)
36         .count();
37     assert_eq!(c, 10);
38 }