public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [FYI] Remove old univariant code from rust-lang.c
@ 2018-04-12 17:07 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2018-04-12 17:07 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Since moving Rust enum handling into dwarf2read.c, some old code for
handling univariant enums in rust-lang.c has been obsolete.  This
patch removes this code.

Tested on x86-64 Fedora 26, using rustc 1.23 (1.24 emits incorrect
DWARF for enums and so can't be used for this test).

2018-04-12  Tom Tromey  <tom@tromey.com>

	* rust-lang.c (rust_print_struct_def): Remove univariant code.
	(rust_evaluate_subexp): Likewise.
---
 gdb/ChangeLog   |  5 +++++
 gdb/rust-lang.c | 25 ++-----------------------
 2 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 66ca520aad..836ac9e100 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2018-04-12  Tom Tromey  <tom@tromey.com>
+
+	* rust-lang.c (rust_print_struct_def): Remove univariant code.
+	(rust_evaluate_subexp): Likewise.
+
 2018-04-12  Pedro Alves  <palves@redhat.com>
 
 	* procfs.c (procfs_detach): Make forward declaration's prototype
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 6e0537f358..cf8a15ee43 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -631,7 +631,6 @@ rust_print_struct_def (struct type *type, const char *varstring,
   bool is_tuple_struct = rust_tuple_struct_type_p (type);
   bool is_tuple = rust_tuple_type_p (type);
   bool is_enum = rust_enum_p (type);
-  bool is_univariant = false;
 
   int enum_discriminant_index = -1;
 
@@ -653,12 +652,6 @@ rust_print_struct_def (struct type *type, const char *varstring,
 	    = (struct discriminant_info *) discriminant_prop->data.baton;
 	  enum_discriminant_index = info->discriminant_index;
 	}
-      else if (TYPE_CODE (type) == TYPE_CODE_UNION && TYPE_NFIELDS (type) == 1)
-	{
-	  /* Probably a univariant enum.  */
-	  fputs_filtered ("enum ", stream);
-	  is_univariant = true;
-	}
       else if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
 	fputs_filtered ("struct ", stream);
       else
@@ -695,19 +688,12 @@ rust_print_struct_def (struct type *type, const char *varstring,
 	    continue;
 	  fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
 	}
-      else if (is_univariant)
-	{
-	  const char *name
-	    = rust_last_path_segment (TYPE_NAME (TYPE_FIELD_TYPE (type, i)));
-	  fputs_filtered (name, stream);
-	}
       else if (!is_tuple_struct)
 	fprintf_filtered (stream, "%s: ", TYPE_FIELD_NAME (type, i));
 
       rust_internal_print_type (TYPE_FIELD_TYPE (type, i), NULL,
-				stream,
-				((is_enum || is_univariant) ? show : show - 1),
-				level + 2, flags, is_enum || is_univariant);
+				stream, (is_enum ? show : show - 1),
+				level + 2, flags, is_enum);
       if (!for_rust_enum)
 	fputs_filtered (",\n", stream);
       else if (i + 1 < TYPE_NFIELDS (type))
@@ -1592,13 +1578,6 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp,
 
         type = value_type (lhs);
 
-	/* Treat a univariant union as if it were an enum.  */
-	if (TYPE_CODE (type) == TYPE_CODE_UNION && TYPE_NFIELDS (type) == 1)
-	  {
-	    lhs = value_primitive_field (lhs, 0, 0, type);
-	    type = value_type (lhs);
-	  }
-
 	if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
 	  {
 	    struct type *outer_type = NULL;
-- 
2.13.6

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-04-12 17:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-12 17:07 [FYI] Remove old univariant code from rust-lang.c Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).