aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/rust-lang.c6
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.rust/simple.exp12
4 files changed, 28 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2016c81..f13305c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2017-02-03 Tom Tromey <tom@tromey.com>
+
+ PR rust/21097:
+ * rust-lang.c (rust_print_type) <TYPE_CODE_UNION>: Handle enums
+ with a single member.
+
2017-02-03 Pedro Alves <palves@redhat.com>
* cli/cli-interp.c (cli_interp_base::cli_interp_base)
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index a804824..105b094 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -977,6 +977,8 @@ rust_print_type (struct type *type, const char *varstring,
skip_to = 0;
}
}
+ else if (TYPE_NFIELDS (type) == 1)
+ skip_to = 0;
for (i = 0; i < TYPE_NFIELDS (type); ++i)
{
@@ -989,7 +991,9 @@ rust_print_type (struct type *type, const char *varstring,
if (TYPE_NFIELDS (variant_type) > skip_to)
{
int first = 1;
- bool is_tuple = rust_tuple_variant_type_p (variant_type);
+ bool is_tuple = (TYPE_NFIELDS (type) == 1
+ ? rust_tuple_struct_type_p (variant_type)
+ : rust_tuple_variant_type_p (variant_type));
int j;
fputs_filtered (is_tuple ? "(" : "{", stream);
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 8c59428..c098bd0 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-02-03 Tom Tromey <tom@tromey.com>
+
+ PR rust/21097:
+ * gdb.rust/simple.exp: Add new tests.
+
2017-02-02 Pedro Alves <palves@redhat.com>
* gdb.mi/mi-logging.exp: Add "redirect while already logging"
diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp
index 50ed70b..0bcc83e 100644
--- a/gdb/testsuite/gdb.rust/simple.exp
+++ b/gdb/testsuite/gdb.rust/simple.exp
@@ -110,6 +110,18 @@ gdb_test "print univariant.a" " = 1"
gdb_test "print univariant_anon" " = simple::UnivariantAnon::Foo\\(1\\)"
gdb_test "print univariant_anon.0" " = 1"
+gdb_test_sequence "ptype simple::Univariant" "" {
+ "type = enum simple::Univariant \\{"
+ " Foo\\{a: u8\\},"
+ "\\}"
+}
+
+gdb_test_sequence "ptype simple::UnivariantAnon" "" {
+ "type = enum simple::UnivariantAnon \\{"
+ " Foo\\(u8\\),"
+ "\\}"
+}
+
gdb_test_sequence "ptype simple::ByeBob" "" {
" = struct simple::ByeBob \\("
" i32,"