about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2014-11-26 17:42:32 +0100
committerMichael Woerister <michaelwoerister@posteo>2014-11-26 17:42:32 +0100
commit67ba096cc30ec0f5fac8deec23d5557012e33d27 (patch)
treee037ee38cec0eb2281605193b8c3f7f0484f516f
parent7608d06027a92ecd5255e760df3847e5418d5d31 (diff)
downloadrust-67ba096cc30ec0f5fac8deec23d5557012e33d27.tar.gz
rust-67ba096cc30ec0f5fac8deec23d5557012e33d27.zip
debuginfo: Fix LLDB pretty printer for enum variants with zero fields.
-rw-r--r--src/etc/lldb_rust_formatters.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/etc/lldb_rust_formatters.py b/src/etc/lldb_rust_formatters.py
index 642235ed4e3..7924d63c8e0 100644
--- a/src/etc/lldb_rust_formatters.py
+++ b/src/etc/lldb_rust_formatters.py
@@ -69,8 +69,14 @@ def print_struct_val_starting_from(field_start_index, val, internal_dict):
   assert val.GetType().GetTypeClass() == lldb.eTypeClassStruct
 
   t = val.GetType()
-  has_field_names = type_has_field_names(t)
   type_name = extract_type_name(t.GetName())
+  num_children = val.num_children
+
+  if (num_children - field_start_index) == 0:
+    # The only field of this struct is the enum discriminant
+    return type_name
+
+  has_field_names = type_has_field_names(t)
 
   if has_field_names:
       template = "%(type_name)s {\n%(body)s\n}"
@@ -83,8 +89,6 @@ def print_struct_val_starting_from(field_start_index, val, internal_dict):
     # this is a tuple, so don't print the type name
     type_name = ""
 
-  num_children = val.num_children
-
   def render_child(child_index):
     this = ""
     if has_field_names:
@@ -105,7 +109,6 @@ def print_enum_val(val, internal_dict):
 
   assert val.GetType().GetTypeClass() == lldb.eTypeClassUnion
 
-
   if val.num_children == 1:
     # This is either an enum with just one variant, or it is an Option-like enum
     # where the discriminant is encoded in a non-nullable pointer field. We find