// // We get an error message at the top of file (dummy span). // This is not helpful, but also kind of annoying to prevent, // so for now just live with it. // This test case was originally for issue #2258. trait ToOpt: Sized { fn to_option(&self) -> Option; } impl ToOpt for usize { fn to_option(&self) -> Option { Some(*self) } } impl ToOpt for Option { fn to_option(&self) -> Option> { Some((*self).clone()) } } fn function(counter: usize, t: T) { //~^ ERROR reached the recursion limit while instantiating `function:: 0 { function(counter - 1, t.to_option()); // FIXME(#4287) Error message should be here. It should be // a type error to instantiate `test` at a type other than T. } } fn main() { function(22, 22); }