]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-45696-no-variant-box-recur.rs
Merge commit '97e504549371d7640cf011d266e3c17394fdddac' into sync_cg_clif-2021-12-20
[rust.git] / src / test / ui / issues / issue-45696-no-variant-box-recur.rs
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,
4 // and #52852).
5 //
6 // We will explicitly test NLL, and migration modes; thus we will also skip the
7 // automated compare-mode=nll.
8
9 // run-pass
10
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
13 #![allow(dead_code)]
14
15 // direct regular recursion with indirect ownership via box
16 struct C { field: Box<C> }
17
18 // direct non-regular recursion with indirect ownership via box
19 struct D { field: Box<(D, D)> }
20
21 // indirect regular recursion with indirect ownership via box.
22 struct E { field: F }
23 struct F { field: Box<E> }
24
25 // indirect non-regular recursion with indirect ownership via box.
26 struct G { field: (H, H) }
27 struct H { field: Box<G> }
28
29 // These enums are cases that are not currently hit by the
30 // `visit_terminator_drop` recursion down a type's structural
31 // definition.
32 //
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>) }
38
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) { }
47
48 fn main() {
49
50 }