]> git.proxmox.com Git - rustc.git/blob - tests/ui/nll/issue-45696-no-variant-box-recur.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / nll / 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 // run-pass
7
8 // This test has structs and functions that are by definition unusable
9 // all over the place, so just go ahead and allow dead_code
10 #![allow(dead_code)]
11
12 // direct regular recursion with indirect ownership via box
13 struct C { field: Box<C> }
14
15 // direct non-regular recursion with indirect ownership via box
16 struct D { field: Box<(D, D)> }
17
18 // indirect regular recursion with indirect ownership via box.
19 struct E { field: F }
20 struct F { field: Box<E> }
21
22 // indirect non-regular recursion with indirect ownership via box.
23 struct G { field: (H, H) }
24 struct H { field: Box<G> }
25
26 // These enums are cases that are not currently hit by the
27 // `visit_terminator_drop` recursion down a type's structural
28 // definition.
29 //
30 // But it seems prudent to include them in this test as variants on
31 // the above, in that they are similarly non-constructable data types
32 // with destructors that would diverge.
33 enum I { One(Box<I>) }
34 enum J { One(Box<J>), Two(Box<J>) }
35
36 fn impossible_to_call_c(_c: C) { }
37 fn impossible_to_call_d(_d: D) { }
38 fn impossible_to_call_e(_e: E) { }
39 fn impossible_to_call_f(_f: F) { }
40 fn impossible_to_call_g(_g: G) { }
41 fn impossible_to_call_h(_h: H) { }
42 fn impossible_to_call_i(_i: I) { }
43 fn impossible_to_call_j(_j: J) { }
44
45 fn main() {
46
47 }