Skip to content

Commit 67ba096

Browse files
debuginfo: Fix LLDB pretty printer for enum variants with zero fields.
1 parent 7608d06 commit 67ba096

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/etc/lldb_rust_formatters.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@ def print_struct_val_starting_from(field_start_index, val, internal_dict):
6969
assert val.GetType().GetTypeClass() == lldb.eTypeClassStruct
7070

7171
t = val.GetType()
72-
has_field_names = type_has_field_names(t)
7372
type_name = extract_type_name(t.GetName())
73+
num_children = val.num_children
74+
75+
if (num_children - field_start_index) == 0:
76+
# The only field of this struct is the enum discriminant
77+
return type_name
78+
79+
has_field_names = type_has_field_names(t)
7480

7581
if has_field_names:
7682
template = "%(type_name)s {\n%(body)s\n}"
@@ -83,8 +89,6 @@ def print_struct_val_starting_from(field_start_index, val, internal_dict):
8389
# this is a tuple, so don't print the type name
8490
type_name = ""
8591

86-
num_children = val.num_children
87-
8892
def render_child(child_index):
8993
this = ""
9094
if has_field_names:
@@ -105,7 +109,6 @@ def print_enum_val(val, internal_dict):
105109

106110
assert val.GetType().GetTypeClass() == lldb.eTypeClassUnion
107111

108-
109112
if val.num_children == 1:
110113
# This is either an enum with just one variant, or it is an Option-like enum
111114
# where the discriminant is encoded in a non-nullable pointer field. We find

0 commit comments

Comments
 (0)