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
13 // ignore-gdb-version: 7.11.90 - 7.12.9
19 // gdb-command:print stack_unique.value
21 // gdbg-command:print stack_unique.next.RUST$ENCODED$ENUM$0$Empty.val->value
22 // gdbr-command:print stack_unique.next.val.value
25 // gdbg-command:print unique_unique->value
26 // gdbr-command:print unique_unique.value
28 // gdbg-command:print unique_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value
29 // gdbr-command:print unique_unique.next.val.value
32 // gdb-command:print vec_unique[0].value
34 // gdbg-command:print vec_unique[0].next.RUST$ENCODED$ENUM$0$Empty.val->value
35 // gdbr-command:print vec_unique[0].next.val.value
38 // gdbg-command:print borrowed_unique->value
39 // gdbr-command:print borrowed_unique.value
41 // gdbg-command:print borrowed_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value
42 // gdbr-command:print borrowed_unique.next.val.value
46 // gdb-command:print long_cycle1.value
48 // gdbg-command:print long_cycle1.next->value
49 // gdbr-command:print long_cycle1.next.value
51 // gdbg-command:print long_cycle1.next->next->value
52 // gdbr-command:print long_cycle1.next.next.value
54 // gdbg-command:print long_cycle1.next->next->next->value
55 // gdbr-command:print long_cycle1.next.next.next.value
58 // gdb-command:print long_cycle2.value
60 // gdbg-command:print long_cycle2.next->value
61 // gdbr-command:print long_cycle2.next.value
63 // gdbg-command:print long_cycle2.next->next->value
64 // gdbr-command:print long_cycle2.next.next.value
67 // gdb-command:print long_cycle3.value
69 // gdbg-command:print long_cycle3.next->value
70 // gdbr-command:print long_cycle3.next.value
73 // gdb-command:print long_cycle4.value
74 // gdb-check:$18 = 29.5
76 // gdbg-command:print (*****long_cycle_w_anonymous_types).value
77 // gdbr-command:print long_cycle_w_anonymous_types.value
80 // gdbg-command:print (*****((*****long_cycle_w_anonymous_types).next.RUST$ENCODED$ENUM$0$Empty.val)).value
81 // gdbr-command:print long_cycle_w_anonymous_types.next.val.value
84 // gdb-command:continue
86 #![allow(unused_variables)]
87 #![feature(box_syntax)]
88 #![feature(omit_gdb_pretty_printer_section)]
89 #![omit_gdb_pretty_printer_section]
91 use self::Opt::{Empty, Val};
98 struct UniqueNode<T> {
99 next: Opt<Box<UniqueNode<T>>>,
103 struct LongCycle1<T> {
104 next: Box<LongCycle2<T>>,
108 struct LongCycle2<T> {
109 next: Box<LongCycle3<T>>,
113 struct LongCycle3<T> {
114 next: Box<LongCycle4<T>>,
118 struct LongCycle4<T> {
119 next: Option<Box<LongCycle1<T>>>,
123 struct LongCycleWithAnonymousTypes {
124 next: Opt<Box<Box<Box<Box<Box<LongCycleWithAnonymousTypes>>>>>>,
128 // This test case makes sure that recursive structs are properly described. The Node structs are
129 // generic so that we can have a new type (that newly needs to be described) for the different
130 // cases. The potential problem with recursive types is that the DI generation algorithm gets
131 // trapped in an endless loop. To make sure, we actually test this in the different cases, we have
132 // to operate on a new type each time, otherwise we would just hit the DI cache for all but the
135 // The different cases below (stack_*, unique_*, box_*, etc) are set up so that the type description
136 // algorithm will enter the type reference cycle that is created by a recursive definition from a
137 // different context each time.
139 // The "long cycle" cases are constructed to span a longer, indirect recursion cycle between types.
140 // The different locals will cause the DI algorithm to enter the type reference cycle at different
144 let stack_unique: UniqueNode<u16> = UniqueNode {
146 val: box UniqueNode {
154 let unique_unique: Box<UniqueNode<u32>> = box UniqueNode {
156 val: box UniqueNode {
164 let vec_unique: [UniqueNode<f32>; 1] = [UniqueNode {
166 val: box UniqueNode {
174 let borrowed_unique: &UniqueNode<f64> = &UniqueNode {
176 val: box UniqueNode {
185 let long_cycle1: LongCycle1<u16> = LongCycle1 {
186 next: box LongCycle2 {
187 next: box LongCycle3 {
188 next: box LongCycle4 {
199 let long_cycle2: LongCycle2<u32> = LongCycle2 {
200 next: box LongCycle3 {
201 next: box LongCycle4 {
210 let long_cycle3: LongCycle3<u64> = LongCycle3 {
211 next: box LongCycle4 {
218 let long_cycle4: LongCycle4<f32> = LongCycle4 {
223 // It's important that LongCycleWithAnonymousTypes is encountered only at the end of the
225 let long_cycle_w_anonymous_types = box box box box box LongCycleWithAnonymousTypes {
227 val: box box box box box LongCycleWithAnonymousTypes {