diff --git a/src/etc/lldb_rust_formatters.py b/src/etc/lldb_rust_formatters.py index 642235ed4e380..7924d63c8e0d5 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