1 // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // ignore-tidy-linelength
17 // gdb-command:print stack_unique.value
19 // gdb-command:print stack_unique.next.RUST$ENCODED$ENUM$0$Empty.val->value
22 // gdb-command:print unique_unique->value
24 // gdb-command:print unique_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value
27 // gdb-command:print vec_unique[0].value
29 // gdb-command:print vec_unique[0].next.RUST$ENCODED$ENUM$0$Empty.val->value
32 // gdb-command:print borrowed_unique->value
34 // gdb-command:print borrowed_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value
38 // gdb-command:print long_cycle1.value
40 // gdb-command:print long_cycle1.next->value
42 // gdb-command:print long_cycle1.next->next->value
44 // gdb-command:print long_cycle1.next->next->next->value
47 // gdb-command:print long_cycle2.value
49 // gdb-command:print long_cycle2.next->value
51 // gdb-command:print long_cycle2.next->next->value
54 // gdb-command:print long_cycle3.value
56 // gdb-command:print long_cycle3.next->value
59 // gdb-command:print long_cycle4.value
60 // gdb-check:$18 = 29.5
62 // gdb-command:print (*****long_cycle_w_anonymous_types).value
65 // gdb-command:print (*****((*****long_cycle_w_anonymous_types).next.RUST$ENCODED$ENUM$0$Empty.val)).value
68 // gdb-command:continue
70 #![allow(unused_variables)]
71 #![feature(box_syntax)]
72 #![feature(omit_gdb_pretty_printer_section)]
73 #![omit_gdb_pretty_printer_section]
75 use self::Opt::{Empty, Val};
82 struct UniqueNode<T> {
83 next: Opt<Box<UniqueNode<T>>>,
87 struct LongCycle1<T> {
88 next: Box<LongCycle2<T>>,
92 struct LongCycle2<T> {
93 next: Box<LongCycle3<T>>,
97 struct LongCycle3<T> {
98 next: Box<LongCycle4<T>>,
102 struct LongCycle4<T> {
103 next: Option<Box<LongCycle1<T>>>,
107 struct LongCycleWithAnonymousTypes {
108 next: Opt<Box<Box<Box<Box<Box<LongCycleWithAnonymousTypes>>>>>>,
112 // This test case makes sure that recursive structs are properly described. The Node structs are
113 // generic so that we can have a new type (that newly needs to be described) for the different
114 // cases. The potential problem with recursive types is that the DI generation algorithm gets
115 // trapped in an endless loop. To make sure, we actually test this in the different cases, we have
116 // to operate on a new type each time, otherwise we would just hit the DI cache for all but the
119 // The different cases below (stack_*, unique_*, box_*, etc) are set up so that the type description
120 // algorithm will enter the type reference cycle that is created by a recursive definition from a
121 // different context each time.
123 // The "long cycle" cases are constructed to span a longer, indirect recursion cycle between types.
124 // The different locals will cause the DI algorithm to enter the type reference cycle at different
128 let stack_unique: UniqueNode<u16> = UniqueNode {
130 val: box UniqueNode {
138 let unique_unique: Box<UniqueNode<u32>> = box UniqueNode {
140 val: box UniqueNode {
148 let vec_unique: [UniqueNode<f32>; 1] = [UniqueNode {
150 val: box UniqueNode {
158 let borrowed_unique: &UniqueNode<f64> = &UniqueNode {
160 val: box UniqueNode {
169 let long_cycle1: LongCycle1<u16> = LongCycle1 {
170 next: box LongCycle2 {
171 next: box LongCycle3 {
172 next: box LongCycle4 {
183 let long_cycle2: LongCycle2<u32> = LongCycle2 {
184 next: box LongCycle3 {
185 next: box LongCycle4 {
194 let long_cycle3: LongCycle3<u64> = LongCycle3 {
195 next: box LongCycle4 {
202 let long_cycle4: LongCycle4<f32> = LongCycle4 {
207 // It's important that LongCycleWithAnonymousTypes is encountered only at the end of the
209 let long_cycle_w_anonymous_types = box box box box box LongCycleWithAnonymousTypes {
211 val: box box box box box LongCycleWithAnonymousTypes {