2024-08-10 02:33:40 +00:00
|
|
|
//@ min-lldb-version: 1800
|
2024-08-13 22:20:48 +00:00
|
|
|
//@ min-gdb-version: 13.0
|
2013-11-04 06:53:01 +00:00
|
|
|
|
2014-02-07 03:57:09 +00:00
|
|
|
//@ compile-flags:-g
|
2014-07-09 12:46:09 +00:00
|
|
|
|
|
|
|
// === GDB TESTS ===================================================================================
|
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:run
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:print some
|
2024-08-27 23:10:22 +00:00
|
|
|
// gdb-check:$1 = core::option::Option<&u32>::Some(0x[...])
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:print none
|
2024-08-17 21:31:49 +00:00
|
|
|
// gdb-check:$2 = core::option::Option<&u32>::None
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:print full
|
2024-08-27 23:10:22 +00:00
|
|
|
// gdb-check:$3 = option_like_enum::MoreFields::Full(454545, 0x[...], 9988)
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2024-08-27 23:10:22 +00:00
|
|
|
// gdb-command:print empty
|
|
|
|
// gdb-check:$4 = option_like_enum::MoreFields::Empty
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:print droid
|
2024-08-27 23:10:22 +00:00
|
|
|
// gdb-check:$5 = option_like_enum::NamedFields::Droid{id: 675675, range: 10000001, internals: 0x[...]}
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2024-08-27 23:10:22 +00:00
|
|
|
// gdb-command:print void_droid
|
|
|
|
// gdb-check:$6 = option_like_enum::NamedFields::Void
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2015-01-08 13:55:13 +00:00
|
|
|
// gdb-command:print nested_non_zero_yep
|
2024-08-17 21:31:49 +00:00
|
|
|
// gdb-check:$7 = option_like_enum::NestedNonZero::Yep(10.5, option_like_enum::NestedNonZeroField {a: 10, b: 20, c: 0x[...]})
|
2015-01-08 13:55:13 +00:00
|
|
|
|
|
|
|
// gdb-command:print nested_non_zero_nope
|
2024-08-17 21:31:49 +00:00
|
|
|
// gdb-check:$8 = option_like_enum::NestedNonZero::Nope
|
2015-01-08 13:55:13 +00:00
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:continue
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2014-07-09 12:46:09 +00:00
|
|
|
|
|
|
|
// === LLDB TESTS ==================================================================================
|
|
|
|
|
|
|
|
// lldb-command:run
|
|
|
|
|
2024-03-15 14:05:57 +00:00
|
|
|
// lldb-command:v some
|
2024-08-27 23:10:22 +00:00
|
|
|
// lldb-check:[...] Some(&0x[...])
|
2014-07-09 12:46:09 +00:00
|
|
|
|
2024-03-15 14:05:57 +00:00
|
|
|
// lldb-command:v none
|
2024-03-10 13:55:58 +00:00
|
|
|
// lldb-check:[...] None
|
2014-07-09 12:46:09 +00:00
|
|
|
|
2024-03-15 14:05:57 +00:00
|
|
|
// lldb-command:v full
|
2024-08-27 23:10:22 +00:00
|
|
|
// lldb-check:[...] Full(454545, &0x[...], 9988)
|
2014-07-09 12:46:09 +00:00
|
|
|
|
2024-03-15 14:05:57 +00:00
|
|
|
// lldb-command:v empty
|
2024-03-10 13:55:58 +00:00
|
|
|
// lldb-check:[...] Empty
|
2014-07-09 12:46:09 +00:00
|
|
|
|
2024-03-15 14:05:57 +00:00
|
|
|
// lldb-command:v droid
|
2024-08-27 23:10:22 +00:00
|
|
|
// lldb-check:[...] Droid { id: 675675, range: 10000001, internals: &0x[...] }
|
2014-07-09 12:46:09 +00:00
|
|
|
|
2024-03-15 14:05:57 +00:00
|
|
|
// lldb-command:v void_droid
|
2024-03-10 13:55:58 +00:00
|
|
|
// lldb-check:[...] Void
|
2014-07-09 12:46:09 +00:00
|
|
|
|
2024-03-15 14:05:57 +00:00
|
|
|
// lldb-command:v some_str
|
2024-03-10 13:55:58 +00:00
|
|
|
// lldb-check:[...] Some("abc")
|
2014-12-02 22:33:52 +00:00
|
|
|
|
2024-03-15 14:05:57 +00:00
|
|
|
// lldb-command:v none_str
|
2024-03-10 13:55:58 +00:00
|
|
|
// lldb-check:[...] None
|
2014-12-02 22:33:52 +00:00
|
|
|
|
2024-03-15 14:05:57 +00:00
|
|
|
// lldb-command:v nested_non_zero_yep
|
2024-03-10 13:55:58 +00:00
|
|
|
// lldb-check:[...] Yep(10.5, NestedNonZeroField { a: 10, b: 20, c: &[...] })
|
2015-01-08 13:55:13 +00:00
|
|
|
|
2024-03-15 14:05:57 +00:00
|
|
|
// lldb-command:v nested_non_zero_nope
|
2024-03-10 13:55:58 +00:00
|
|
|
// lldb-check:[...] Nope
|
2015-01-08 13:55:13 +00:00
|
|
|
|
2014-07-09 12:46:09 +00:00
|
|
|
|
2015-09-19 20:33:47 +00:00
|
|
|
#![feature(omit_gdb_pretty_printer_section)]
|
2014-12-03 22:48:18 +00:00
|
|
|
#![omit_gdb_pretty_printer_section]
|
|
|
|
|
2013-07-15 13:48:57 +00:00
|
|
|
// If a struct has exactly two variants, one of them is empty, and the other one
|
|
|
|
// contains a non-nullable pointer, then this value is used as the discriminator.
|
|
|
|
// The test cases in this file make sure that something readable is generated for
|
|
|
|
// this kind of types.
|
|
|
|
|
2013-12-10 07:16:18 +00:00
|
|
|
enum MoreFields<'a> {
|
2014-12-06 02:12:25 +00:00
|
|
|
Full(u32, &'a isize, i16),
|
2013-07-15 13:48:57 +00:00
|
|
|
Empty
|
|
|
|
}
|
|
|
|
|
2013-12-10 07:16:18 +00:00
|
|
|
struct MoreFieldsRepr<'a> {
|
2013-08-08 12:14:52 +00:00
|
|
|
a: u32,
|
2014-12-06 02:12:25 +00:00
|
|
|
discr: &'a isize,
|
2013-08-08 12:14:52 +00:00
|
|
|
b: i16
|
|
|
|
}
|
|
|
|
|
2013-12-10 07:16:18 +00:00
|
|
|
enum NamedFields<'a> {
|
2014-12-06 02:12:25 +00:00
|
|
|
Droid { id: i32, range: i64, internals: &'a isize },
|
2013-07-15 13:48:57 +00:00
|
|
|
Void
|
|
|
|
}
|
|
|
|
|
2013-12-10 07:16:18 +00:00
|
|
|
struct NamedFieldsRepr<'a> {
|
2013-08-08 12:14:52 +00:00
|
|
|
id: i32,
|
|
|
|
range: i64,
|
2014-12-06 02:12:25 +00:00
|
|
|
internals: &'a isize
|
2013-08-08 12:14:52 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 13:55:13 +00:00
|
|
|
struct NestedNonZeroField<'a> {
|
|
|
|
a: u16,
|
|
|
|
b: u32,
|
|
|
|
c: &'a char,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum NestedNonZero<'a> {
|
|
|
|
Yep(f64, NestedNonZeroField<'a>),
|
|
|
|
Nope
|
|
|
|
}
|
|
|
|
|
2013-07-15 13:48:57 +00:00
|
|
|
fn main() {
|
|
|
|
|
2014-12-02 22:33:52 +00:00
|
|
|
let some_str: Option<&'static str> = Some("abc");
|
|
|
|
let none_str: Option<&'static str> = None;
|
|
|
|
|
2024-08-27 23:10:22 +00:00
|
|
|
let some: Option<&u32> = Some(&1234);
|
2013-07-16 10:17:55 +00:00
|
|
|
let none: Option<&u32> = None;
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2024-08-27 23:10:22 +00:00
|
|
|
let full = MoreFields::Full(454545, &1234, 9988);
|
2014-11-06 08:05:53 +00:00
|
|
|
let empty = MoreFields::Empty;
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2014-11-06 08:05:53 +00:00
|
|
|
let droid = NamedFields::Droid {
|
2013-08-08 12:14:52 +00:00
|
|
|
id: 675675,
|
|
|
|
range: 10000001,
|
2024-08-27 23:10:22 +00:00
|
|
|
internals: &1234,
|
2013-08-08 12:14:52 +00:00
|
|
|
};
|
2014-11-06 08:05:53 +00:00
|
|
|
let void_droid = NamedFields::Void;
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2015-01-08 13:55:13 +00:00
|
|
|
let nested_non_zero_yep = NestedNonZero::Yep(
|
|
|
|
10.5,
|
|
|
|
NestedNonZeroField {
|
|
|
|
a: 10,
|
|
|
|
b: 20,
|
2024-08-27 23:10:22 +00:00
|
|
|
c: &'x',
|
2015-01-08 13:55:13 +00:00
|
|
|
});
|
|
|
|
let nested_non_zero_nope = NestedNonZero::Nope;
|
|
|
|
|
2014-07-09 12:46:09 +00:00
|
|
|
zzz(); // #break
|
2013-07-15 13:48:57 +00:00
|
|
|
}
|
|
|
|
|
2013-08-08 12:14:52 +00:00
|
|
|
fn zzz() {()}
|