@@ -51,7 +51,7 @@ def rust_pretty_printer_lookup_function(val):
51
51
enum_member_count = len (enum_members )
52
52
53
53
if enum_member_count == 0 :
54
- return RustStructPrinter (val , false )
54
+ return RustStructPrinter (val , False )
55
55
56
56
if enum_member_count == 1 :
57
57
first_variant_name = enum_members [0 ].name
@@ -60,7 +60,11 @@ def rust_pretty_printer_lookup_function(val):
60
60
return rust_pretty_printer_lookup_function (val [enum_members [0 ]])
61
61
else :
62
62
assert first_variant_name .startswith ("RUST$ENCODED$ENUM$" )
63
- # This is a space-optimized enum
63
+ # This is a space-optimized enum.
64
+ # This means this enum has only two states, and Rust uses one of the
65
+ # fields somewhere in the struct to determine which of the two states
66
+ # it's in. The location of the field is encoded in the name as something
67
+ # like RUST$ENCODED$ENUM$(num$)*name_of_zero_state
64
68
last_separator_index = first_variant_name .rfind ("$" )
65
69
start_index = len ("RUST$ENCODED$ENUM$" )
66
70
disr_field_indices = first_variant_name [start_index :
@@ -76,7 +80,7 @@ def rust_pretty_printer_lookup_function(val):
76
80
# If the discriminant field is a fat pointer we have to consider the
77
81
# first word as the true discriminant
78
82
if discriminant .type .code == gdb .TYPE_CODE_STRUCT :
79
- discriminant = discriminant [get_field_at_index (discriminant , 0 )]
83
+ discriminant = discriminant [get_field_at_index (discriminant , 0 )]
80
84
81
85
if discriminant == 0 :
82
86
null_variant_name = first_variant_name [last_separator_index + 1 :]
0 commit comments