]> git.lizzy.rs Git - rust.git/blob - tests/ui/recursion/issue-95134.rs
Rollup merge of #106759 - compiler-errors:revert-105255, r=cjgillot
[rust.git] / tests / ui / recursion / issue-95134.rs
1 // build-fail
2 // known-bug: #95134
3 // compile-flags: -Copt-level=0
4 // failure-status: 101
5 // dont-check-compiler-stderr
6
7 pub fn encode_num<Writer: ExampleWriter>(n: u32, mut writer: Writer) -> Result<(), Writer::Error> {
8     if n > 15 {
9         encode_num(n / 16, &mut writer)?;
10     }
11     Ok(())
12 }
13
14 pub trait ExampleWriter {
15     type Error;
16 }
17
18 impl<'a, T: ExampleWriter> ExampleWriter for &'a mut T {
19     type Error = T::Error;
20 }
21
22 struct EmptyWriter;
23
24 impl ExampleWriter for EmptyWriter {
25     type Error = ();
26 }
27
28 fn main() {
29     encode_num(69, &mut EmptyWriter).unwrap();
30 }