2014-07-09 07:46:09 -05:00
|
|
|
//@ ignore-lldb
|
2018-09-26 13:58:10 -05:00
|
|
|
|
2014-02-06 21:57:09 -06:00
|
|
|
//@ compile-flags:-g
|
2016-10-25 16:32:04 -05:00
|
|
|
|
2014-04-24 04:35:48 -05:00
|
|
|
// gdb-command:run
|
|
|
|
|
|
|
|
// gdb-command:print stack_unique.value
|
|
|
|
// gdb-check:$1 = 0
|
2024-08-17 16:31:49 -05:00
|
|
|
// gdb-command:print stack_unique.next.val.value
|
2014-04-24 04:35:48 -05:00
|
|
|
// gdb-check:$2 = 1
|
|
|
|
|
2024-08-17 16:31:49 -05:00
|
|
|
// gdb-command:print unique_unique.value
|
2014-04-24 04:35:48 -05:00
|
|
|
// gdb-check:$3 = 2
|
2024-08-17 16:31:49 -05:00
|
|
|
// gdb-command:print unique_unique.next.val.value
|
2014-04-24 04:35:48 -05:00
|
|
|
// gdb-check:$4 = 3
|
|
|
|
|
|
|
|
// gdb-command:print vec_unique[0].value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$5 = 6.5
|
2024-08-17 16:31:49 -05:00
|
|
|
// gdb-command:print vec_unique[0].next.val.value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$6 = 7.5
|
2014-04-24 04:35:48 -05:00
|
|
|
|
2024-08-17 16:31:49 -05:00
|
|
|
// gdb-command:print borrowed_unique.value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$7 = 8.5
|
2024-08-17 16:31:49 -05:00
|
|
|
// gdb-command:print borrowed_unique.next.val.value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$8 = 9.5
|
2013-09-13 04:41:49 -05:00
|
|
|
|
|
|
|
// LONG CYCLE
|
2014-04-24 04:35:48 -05:00
|
|
|
// gdb-command:print long_cycle1.value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$9 = 20
|
2024-08-17 16:31:49 -05:00
|
|
|
// gdb-command:print long_cycle1.next.value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$10 = 21
|
2024-08-17 16:31:49 -05:00
|
|
|
// gdb-command:print long_cycle1.next.next.value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$11 = 22
|
2024-08-17 16:31:49 -05:00
|
|
|
// gdb-command:print long_cycle1.next.next.next.value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$12 = 23
|
2014-04-24 04:35:48 -05:00
|
|
|
|
|
|
|
// gdb-command:print long_cycle2.value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$13 = 24
|
2024-08-17 16:31:49 -05:00
|
|
|
// gdb-command:print long_cycle2.next.value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$14 = 25
|
2024-08-17 16:31:49 -05:00
|
|
|
// gdb-command:print long_cycle2.next.next.value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$15 = 26
|
2014-04-24 04:35:48 -05:00
|
|
|
|
|
|
|
// gdb-command:print long_cycle3.value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$16 = 27
|
2024-08-17 16:31:49 -05:00
|
|
|
// gdb-command:print long_cycle3.next.value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$17 = 28
|
2014-04-24 04:35:48 -05:00
|
|
|
|
|
|
|
// gdb-command:print long_cycle4.value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$18 = 29.5
|
2014-04-24 04:35:48 -05:00
|
|
|
|
2024-08-17 16:31:49 -05:00
|
|
|
// gdb-command:print long_cycle_w_anon_types.value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$19 = 30
|
2014-04-24 04:35:48 -05:00
|
|
|
|
2024-08-17 16:31:49 -05:00
|
|
|
// gdb-command:print long_cycle_w_anon_types.next.val.value
|
2014-10-02 17:12:58 -05:00
|
|
|
// gdb-check:$20 = 31
|
2014-04-24 04:35:48 -05:00
|
|
|
|
|
|
|
// gdb-command:continue
|
2013-09-13 04:41:49 -05:00
|
|
|
|
2014-10-27 17:37:07 -05:00
|
|
|
#![allow(unused_variables)]
|
2015-09-19 15:33:47 -05:00
|
|
|
#![feature(omit_gdb_pretty_printer_section)]
|
2014-12-03 16:48:18 -06:00
|
|
|
#![omit_gdb_pretty_printer_section]
|
2013-09-13 04:41:49 -05:00
|
|
|
|
2014-11-06 02:05:53 -06:00
|
|
|
use self::Opt::{Empty, Val};
|
2021-08-24 19:39:40 -05:00
|
|
|
use std::boxed::Box as B;
|
2014-11-06 02:05:53 -06:00
|
|
|
|
2013-09-13 04:41:49 -05:00
|
|
|
enum Opt<T> {
|
|
|
|
Empty,
|
|
|
|
Val { val: T }
|
|
|
|
}
|
|
|
|
|
|
|
|
struct UniqueNode<T> {
|
2014-05-05 20:56:44 -05:00
|
|
|
next: Opt<Box<UniqueNode<T>>>,
|
2013-09-13 04:41:49 -05:00
|
|
|
value: T
|
|
|
|
}
|
|
|
|
|
|
|
|
struct LongCycle1<T> {
|
2014-05-05 20:56:44 -05:00
|
|
|
next: Box<LongCycle2<T>>,
|
2013-09-13 04:41:49 -05:00
|
|
|
value: T,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct LongCycle2<T> {
|
2014-05-05 20:56:44 -05:00
|
|
|
next: Box<LongCycle3<T>>,
|
2013-09-13 04:41:49 -05:00
|
|
|
value: T,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct LongCycle3<T> {
|
2014-05-05 20:56:44 -05:00
|
|
|
next: Box<LongCycle4<T>>,
|
2013-09-13 04:41:49 -05:00
|
|
|
value: T,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct LongCycle4<T> {
|
2014-05-05 20:56:44 -05:00
|
|
|
next: Option<Box<LongCycle1<T>>>,
|
2013-09-13 04:41:49 -05:00
|
|
|
value: T,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct LongCycleWithAnonymousTypes {
|
2014-05-05 20:56:44 -05:00
|
|
|
next: Opt<Box<Box<Box<Box<Box<LongCycleWithAnonymousTypes>>>>>>,
|
2015-03-25 19:06:52 -05:00
|
|
|
value: usize,
|
2013-09-13 04:41:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// This test case makes sure that recursive structs are properly described. The Node structs are
|
|
|
|
// generic so that we can have a new type (that newly needs to be described) for the different
|
2013-09-13 09:26:35 -05:00
|
|
|
// cases. The potential problem with recursive types is that the DI generation algorithm gets
|
|
|
|
// trapped in an endless loop. To make sure, we actually test this in the different cases, we have
|
|
|
|
// to operate on a new type each time, otherwise we would just hit the DI cache for all but the
|
|
|
|
// first case.
|
2013-09-13 04:41:49 -05:00
|
|
|
|
|
|
|
// The different cases below (stack_*, unique_*, box_*, etc) are set up so that the type description
|
|
|
|
// algorithm will enter the type reference cycle that is created by a recursive definition from a
|
2013-09-13 09:26:35 -05:00
|
|
|
// different context each time.
|
2013-09-13 04:41:49 -05:00
|
|
|
|
|
|
|
// The "long cycle" cases are constructed to span a longer, indirect recursion cycle between types.
|
|
|
|
// The different locals will cause the DI algorithm to enter the type reference cycle at different
|
|
|
|
// points.
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let stack_unique: UniqueNode<u16> = UniqueNode {
|
|
|
|
next: Val {
|
2021-08-24 19:39:40 -05:00
|
|
|
val: Box::new(UniqueNode {
|
2013-09-13 04:41:49 -05:00
|
|
|
next: Empty,
|
2015-03-03 02:42:26 -06:00
|
|
|
value: 1,
|
2021-08-24 19:39:40 -05:00
|
|
|
})
|
2013-09-13 04:41:49 -05:00
|
|
|
},
|
2015-03-03 02:42:26 -06:00
|
|
|
value: 0,
|
2013-09-13 04:41:49 -05:00
|
|
|
};
|
|
|
|
|
2021-08-24 19:39:40 -05:00
|
|
|
let unique_unique: Box<UniqueNode<u32>> = Box::new(UniqueNode {
|
2013-09-13 04:41:49 -05:00
|
|
|
next: Val {
|
2021-08-24 19:39:40 -05:00
|
|
|
val: Box::new(UniqueNode {
|
2013-09-13 04:41:49 -05:00
|
|
|
next: Empty,
|
|
|
|
value: 3,
|
2021-08-24 19:39:40 -05:00
|
|
|
})
|
2013-09-13 04:41:49 -05:00
|
|
|
},
|
|
|
|
value: 2,
|
2021-08-24 19:39:40 -05:00
|
|
|
});
|
2013-09-13 04:41:49 -05:00
|
|
|
|
2014-12-19 20:20:51 -06:00
|
|
|
let vec_unique: [UniqueNode<f32>; 1] = [UniqueNode {
|
2013-09-13 04:41:49 -05:00
|
|
|
next: Val {
|
2021-08-24 19:39:40 -05:00
|
|
|
val: Box::new(UniqueNode {
|
2013-09-13 04:41:49 -05:00
|
|
|
next: Empty,
|
|
|
|
value: 7.5,
|
2021-08-24 19:39:40 -05:00
|
|
|
})
|
2013-09-13 04:41:49 -05:00
|
|
|
},
|
|
|
|
value: 6.5,
|
|
|
|
}];
|
|
|
|
|
|
|
|
let borrowed_unique: &UniqueNode<f64> = &UniqueNode {
|
|
|
|
next: Val {
|
2021-08-24 19:39:40 -05:00
|
|
|
val: Box::new(UniqueNode {
|
2013-09-13 04:41:49 -05:00
|
|
|
next: Empty,
|
|
|
|
value: 9.5,
|
2021-08-24 19:39:40 -05:00
|
|
|
})
|
2013-09-13 04:41:49 -05:00
|
|
|
},
|
|
|
|
value: 8.5,
|
|
|
|
};
|
|
|
|
|
|
|
|
// LONG CYCLE
|
|
|
|
let long_cycle1: LongCycle1<u16> = LongCycle1 {
|
2021-08-24 19:39:40 -05:00
|
|
|
next: Box::new(LongCycle2 {
|
|
|
|
next: Box::new(LongCycle3 {
|
|
|
|
next: Box::new(LongCycle4 {
|
2013-09-13 04:41:49 -05:00
|
|
|
next: None,
|
|
|
|
value: 23,
|
2021-08-24 19:39:40 -05:00
|
|
|
}),
|
2013-09-13 04:41:49 -05:00
|
|
|
value: 22,
|
2021-08-24 19:39:40 -05:00
|
|
|
}),
|
2013-09-13 04:41:49 -05:00
|
|
|
value: 21
|
2021-08-24 19:39:40 -05:00
|
|
|
}),
|
2013-09-13 04:41:49 -05:00
|
|
|
value: 20
|
|
|
|
};
|
|
|
|
|
|
|
|
let long_cycle2: LongCycle2<u32> = LongCycle2 {
|
2021-08-24 19:39:40 -05:00
|
|
|
next: Box::new(LongCycle3 {
|
|
|
|
next: Box::new(LongCycle4 {
|
2013-09-13 04:41:49 -05:00
|
|
|
next: None,
|
|
|
|
value: 26,
|
2021-08-24 19:39:40 -05:00
|
|
|
}),
|
2013-09-13 04:41:49 -05:00
|
|
|
value: 25,
|
2021-08-24 19:39:40 -05:00
|
|
|
}),
|
2013-09-13 04:41:49 -05:00
|
|
|
value: 24
|
|
|
|
};
|
|
|
|
|
|
|
|
let long_cycle3: LongCycle3<u64> = LongCycle3 {
|
2021-08-24 19:39:40 -05:00
|
|
|
next: Box::new(LongCycle4 {
|
2013-09-13 04:41:49 -05:00
|
|
|
next: None,
|
|
|
|
value: 28,
|
2021-08-24 19:39:40 -05:00
|
|
|
}),
|
2013-09-13 04:41:49 -05:00
|
|
|
value: 27,
|
|
|
|
};
|
|
|
|
|
|
|
|
let long_cycle4: LongCycle4<f32> = LongCycle4 {
|
|
|
|
next: None,
|
|
|
|
value: 29.5,
|
|
|
|
};
|
|
|
|
|
|
|
|
// It's important that LongCycleWithAnonymousTypes is encountered only at the end of the
|
2014-05-05 20:56:44 -05:00
|
|
|
// `box` chain.
|
2021-08-24 19:39:40 -05:00
|
|
|
let long_cycle_w_anon_types = B::new(B::new(B::new(B::new(B::new(LongCycleWithAnonymousTypes {
|
2013-09-13 04:41:49 -05:00
|
|
|
next: Val {
|
2021-08-24 19:39:40 -05:00
|
|
|
val: Box::new(Box::new(Box::new(Box::new(Box::new(LongCycleWithAnonymousTypes {
|
2013-09-13 04:41:49 -05:00
|
|
|
next: Empty,
|
|
|
|
value: 31,
|
2021-08-24 19:39:40 -05:00
|
|
|
})))))
|
2013-09-13 04:41:49 -05:00
|
|
|
},
|
|
|
|
value: 30
|
2021-08-24 19:39:40 -05:00
|
|
|
})))));
|
2013-09-13 04:41:49 -05:00
|
|
|
|
2014-10-29 01:13:29 -05:00
|
|
|
zzz(); // #break
|
2013-09-13 04:41:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn zzz() {()}
|