1 // build-fail
2 // normalize-stderr-test: ".nll/" -> "/"
3 
4 trait ToOpt: Sized {
to_option(&self) -> Option<Self>5     fn to_option(&self) -> Option<Self>;
6 }
7 
8 impl ToOpt for usize {
to_option(&self) -> Option<usize>9     fn to_option(&self) -> Option<usize> {
10         Some(*self)
11     }
12 }
13 
14 impl<T:Clone> ToOpt for Option<T> {
to_option(&self) -> Option<Option<T>>15     fn to_option(&self) -> Option<Option<T>> {
16         Some((*self).clone())
17     }
18 }
19 
function<T:ToOpt + Clone>(counter: usize, t: T)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 
main()27 fn main() {
28     function(22, 22);
29 }
30