]> git.lizzy.rs Git - rust.git/blob - tests/ui/traits/issue-91949-hangs-on-recursion.rs
Merge commit '7f27e2e74ef957baa382dc05cf08df6368165c74' into clippyup
[rust.git] / tests / ui / traits / issue-91949-hangs-on-recursion.rs
1 // build-fail
2 // compile-flags: -Zinline-mir=no
3 // error-pattern: overflow evaluating the requirement `(): Sized`
4 // error-pattern: function cannot return without recursing
5 // normalize-stderr-test: "long-type-\d+" -> "long-type-hash"
6
7 // Regression test for #91949.
8 // This hanged *forever* on 1.56, fixed by #90423.
9
10 #![recursion_limit = "256"]
11
12 struct Wrapped<T>(T);
13
14 struct IteratorOfWrapped<T, I: Iterator<Item = T>>(I);
15
16 impl<T, I: Iterator<Item = T>> Iterator for IteratorOfWrapped<T, I> {
17     type Item = Wrapped<T>;
18     fn next(&mut self) -> Option<Wrapped<T>> {
19         self.0.next().map(Wrapped)
20     }
21 }
22
23 fn recurse<T>(elements: T) -> Vec<char>
24 where
25     T: Iterator<Item = ()>,
26 {
27     recurse(IteratorOfWrapped(elements).map(|t| t.0))
28 }
29
30 fn main() {
31     recurse(std::iter::empty());
32 }