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.
9 // revisions: nll migrate
10 // ignore-compare-mode-nll
12 #![cfg_attr(nll, feature(nll))]
16 // This test has structs and functions that are by definition unusable
17 // all over the place, so just go ahead and allow dead_code
20 // direct regular recursion with indirect ownership via box
21 struct C { field: Box<C> }
23 // direct non-regular recursion with indirect ownership via box
24 struct D { field: Box<(D, D)> }
26 // indirect regular recursion with indirect ownership via box.
28 struct F { field: Box<E> }
30 // indirect non-regular recursion with indirect ownership via box.
31 struct G { field: (H, H) }
32 struct H { field: Box<G> }
34 // These enums are cases that are not currently hit by the
35 // `visit_terminator_drop` recursion down a type's structural
38 // But it seems prudent to include them in this test as variants on
39 // the above, in that they are similarly non-constructable data types
40 // with destructors that would diverge.
41 enum I { One(Box<I>) }
42 enum J { One(Box<J>), Two(Box<J>) }
44 fn impossible_to_call_c(_c: C) { }
45 fn impossible_to_call_d(_d: D) { }
46 fn impossible_to_call_e(_e: E) { }
47 fn impossible_to_call_f(_f: F) { }
48 fn impossible_to_call_g(_g: G) { }
49 fn impossible_to_call_h(_h: H) { }
50 fn impossible_to_call_i(_i: I) { }
51 fn impossible_to_call_j(_j: J) { }