1 // rust-lang/rust#45696: This test checks the compiler won't infinite loop when
2 // you declare a variable of type `struct A(Box<A>, ...);` (which is impossible
3 // to construct but *is* possible to declare; see also issues #4287, #44933,
6 // We will explicitly test NLL, and migration modes; thus we will also skip the
7 // automated compare-mode=nll.
11 // This test has structs and functions that are by definition unusable
12 // all over the place, so just go ahead and allow dead_code
15 // direct regular recursion with indirect ownership via box
16 struct C { field: Box<C> }
18 // direct non-regular recursion with indirect ownership via box
19 struct D { field: Box<(D, D)> }
21 // indirect regular recursion with indirect ownership via box.
23 struct F { field: Box<E> }
25 // indirect non-regular recursion with indirect ownership via box.
26 struct G { field: (H, H) }
27 struct H { field: Box<G> }
29 // These enums are cases that are not currently hit by the
30 // `visit_terminator_drop` recursion down a type's structural
33 // But it seems prudent to include them in this test as variants on
34 // the above, in that they are similarly non-constructable data types
35 // with destructors that would diverge.
36 enum I { One(Box<I>) }
37 enum J { One(Box<J>), Two(Box<J>) }
39 fn impossible_to_call_c(_c: C) { }
40 fn impossible_to_call_d(_d: D) { }
41 fn impossible_to_call_e(_e: E) { }
42 fn impossible_to_call_f(_f: F) { }
43 fn impossible_to_call_g(_g: G) { }
44 fn impossible_to_call_h(_h: H) { }
45 fn impossible_to_call_i(_i: I) { }
46 fn impossible_to_call_j(_j: J) { }