]> git.lizzy.rs Git - rust.git/blob - tests/ui/infinite/infinite-instantiation.rs
Bless tests after rebase
[rust.git] / tests / ui / infinite / infinite-instantiation.rs
1 // build-fail
2 // normalize-stderr-test: ".nll/" -> "/"
3
4 trait ToOpt: Sized {
5     fn to_option(&self) -> Option<Self>;
6 }
7
8 impl ToOpt for usize {
9     fn to_option(&self) -> Option<usize> {
10         Some(*self)
11     }
12 }
13
14 impl<T:Clone> ToOpt for Option<T> {
15     fn to_option(&self) -> Option<Option<T>> {
16         Some((*self).clone())
17     }
18 }
19
20 fn function<T:ToOpt + Clone>(counter: usize, t: T) {
21     if counter > 0 {
22         function(counter - 1, t.to_option());
23         //~^ ERROR reached the recursion limit while instantiating `function::<Option<
24     }
25 }
26
27 fn main() {
28     function(22, 22);
29 }