about summary refs log tree commit diff
path: root/src/etc/debugger_pretty_printers_common.py
diff options
context:
space:
mode:
authorPhilip Craig <philipjcraig@gmail.com>2017-01-01 17:46:15 +1000
committerPhilip Craig <philipjcraig@gmail.com>2017-01-01 19:34:06 +1000
commit1765a3fd30b12e8647e79f9caf873c800df42bf9 (patch)
tree1d7d0ca42f626785f0140dc4adc417a6eed8d7a2 /src/etc/debugger_pretty_printers_common.py
parent08babdb412a87960fe3602e92abf1bf5fe26a8da (diff)
downloadrust-1765a3fd30b12e8647e79f9caf873c800df42bf9.tar.gz
rust-1765a3fd30b12e8647e79f9caf873c800df42bf9.zip
Add pretty printing of unions in debuggers
Fixes #37479
Diffstat (limited to 'src/etc/debugger_pretty_printers_common.py')
-rw-r--r--src/etc/debugger_pretty_printers_common.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/etc/debugger_pretty_printers_common.py b/src/etc/debugger_pretty_printers_common.py
index eb562877c85..5e3ff5246a9 100644
--- a/src/etc/debugger_pretty_printers_common.py
+++ b/src/etc/debugger_pretty_printers_common.py
@@ -45,6 +45,7 @@ TYPE_KIND_SINGLETON_ENUM    = 13
 TYPE_KIND_CSTYLE_ENUM       = 14
 TYPE_KIND_PTR               = 15
 TYPE_KIND_FIXED_SIZE_VEC    = 16
+TYPE_KIND_REGULAR_UNION     = 17
 
 ENCODED_ENUM_PREFIX = "RUST$ENCODED$ENUM$"
 ENUM_DISR_FIELD_NAME = "RUST$ENUM$DISR"
@@ -188,15 +189,18 @@ class Type(object):
         union_member_count = len(union_members)
         if union_member_count == 0:
             return TYPE_KIND_EMPTY
-        elif union_member_count == 1:
-            first_variant_name = union_members[0].name
-            if first_variant_name is None:
+
+        first_variant_name = union_members[0].name
+        if first_variant_name is None:
+            if union_member_count == 1:
                 return TYPE_KIND_SINGLETON_ENUM
             else:
-                assert first_variant_name.startswith(ENCODED_ENUM_PREFIX)
-                return TYPE_KIND_COMPRESSED_ENUM
+                return TYPE_KIND_REGULAR_ENUM
+        elif first_variant_name.startswith(ENCODED_ENUM_PREFIX):
+            assert union_member_count == 1
+            return TYPE_KIND_COMPRESSED_ENUM
         else:
-            return TYPE_KIND_REGULAR_ENUM
+            return TYPE_KIND_REGULAR_UNION
 
 
     def __conforms_to_field_layout(self, expected_fields):