]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-45696-no-variant-box-recur.rs
b5d9036aba67cf3912f54a2dd65780b1d7c2a84d
[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 // revisions: nll migrate
10 // ignore-compare-mode-nll
11
12 #![cfg_attr(nll, feature(nll))]
13
14 // run-pass
15
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
18 #![allow(dead_code)]
19
20 // direct regular recursion with indirect ownership via box
21 struct C { field: Box<C> }
22
23 // direct non-regular recursion with indirect ownership via box
24 struct D { field: Box<(D, D)> }
25
26 // indirect regular recursion with indirect ownership via box.
27 struct E { field: F }
28 struct F { field: Box<E> }
29
30 // indirect non-regular recursion with indirect ownership via box.
31 struct G { field: (H, H) }
32 struct H { field: Box<G> }
33
34 // These enums are cases that are not currently hit by the
35 // `visit_terminator_drop` recursion down a type's structural
36 // definition.
37 //
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>) }
43
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) { }
52
53 fn main() {
54
55 }