]> git.lizzy.rs Git - rust.git/blob - src/test/ui/autoref-autoderef/issue-38940.rs
Auto merge of #102684 - JhonnyBillM:delete-target-data-layout-errors-wrapper, r=davidtwco
[rust.git] / src / test / ui / autoref-autoderef / issue-38940.rs
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 // compile-flags: -Zdeduplicate-diagnostics=yes
6
7 #![allow(dead_code)]
8 #![recursion_limit = "10"]
9 macro_rules! link {
10     ($outer:ident, $inner:ident) => {
11         struct $outer($inner);
12         impl $outer {
13             fn new() -> $outer {
14                 $outer($inner::new())
15             }
16         }
17         impl std::ops::Deref for $outer {
18             type Target = $inner;
19             fn deref(&self) -> &$inner {
20                 &self.0
21             }
22         }
23     };
24 }
25
26 struct Bottom;
27
28 impl Bottom {
29     fn new() -> Bottom {
30         Bottom
31     }
32 }
33
34 link!(Top, A);
35 link!(A, B);
36 link!(B, C);
37 link!(C, D);
38 link!(D, E);
39 link!(E, F);
40 link!(F, G);
41 link!(G, H);
42 link!(H, I);
43 link!(I, J);
44 link!(J, K);
45 link!(K, Bottom);
46
47 fn main() {
48     let t = Top::new();
49     let x: &Bottom = &t;
50     //~^ ERROR mismatched types
51     //~| ERROR reached the recursion limit while auto-dereferencing `J`
52 }