1 // issue-38940: error printed twice for deref recursion limit exceeded
2 // Test that the recursion limit can be changed. In this case, we have
3 // deeply nested types that will fail the `Send` check by overflow
4 // when the recursion limit is set very low.
5 #![allow(dead_code)]
6 #![recursion_limit="10"]
7 macro_rules! link {
8     ($outer:ident, $inner:ident) => {
9         struct $outer($inner);
10         impl $outer {
11             fn new() -> $outer {
12                 $outer($inner::new())
13             }
14         }
15         impl std::ops::Deref for $outer {
16             type Target = $inner;
17             fn deref(&self) -> &$inner {
18                 &self.0
19             }
20         }
21     }
22 }
23 struct Bottom;
24 impl Bottom {
new() -> Bottom25     fn new() -> Bottom {
26         Bottom
27     }
28 }
29 link!(Top, A);
30 link!(A, B);
31 link!(B, C);
32 link!(C, D);
33 link!(D, E);
34 link!(E, F);
35 link!(F, G);
36 link!(G, H);
37 link!(H, I);
38 link!(I, J);
39 link!(J, K);
40 link!(K, Bottom);
main()41 fn main() {
42     let t = Top::new();
43     let x: &Bottom = &t;
44     //~^ ERROR mismatched types
45     //~| ERROR reached the recursion limit while auto-dereferencing `J`
46 }
47