Change:
Debuginfo for (and probably also ) enums is not correct if the pointer that doubles as discriminant is a fat pointer. Steps to reproduce: (1) Compile the following program with (2) Print the value of in LLDB with pretty printers enabled: This should print instead of . Maybe it's just the LLDB pretty printer that needs to be adapted.

Discussion:
return RustStructPrinter(val, false) if enum_member_count == 1: <del> if enum_members[0].name == None: </del> <ins> first_variant_name = enum_members[0].name if first_variant_name == None: </ins> # This is a singleton enum return rust_pretty_printer_lookup_function(val[enum_members[0]]) else: <del> assert enum_members[0].name.startswith("RUST$ENCODED$ENUM$") </del> <ins> assert first_variant_name.startswith("RUST$ENCODED$ENUM$") </ins> # This is a space-optimized enum <del> last_separator_index = enum_members[0].name.rfind("$") </del> <ins> last_separator_index = first_variant_name.rfind("$") </ins> second_last_separator_index = first_variant_name.rfind("$", 0, last_separator_index) disr_field_index = first_variant_name[second_last_separator_index + 1 : last_separator_index]

sole_variant_val = val[enum_members[0]] disr_field = get_field_at_index(sole_variant_val, disr_field_index) <del> discriminant = int(sole_variant_val[disr_field]) </del> <ins> discriminant = sole_variant_val[disr_field] # If the discriminant field is a fat pointer we have to consider the # first word as the true discriminant if discriminant.type.code == gdb.TYPE_CODE_STRUCT: discriminant = discriminant[get_field_at_index(discriminant, 0)] </ins> if discriminant == 0: null_variant_name = first_variant_name[last_separator_index + 1:]

class IdentityPrinter: def __init__(self, string): <del> self.string </del> <ins> self.string = string </ins> def to_string(self): return self.string

// gdb-command: print none // gdb-check:$12 = None <ins> // gdb-command: print some_fat // gdb-check:$13 = Some = {"abc"} // gdb-command: print none_fat // gdb-check:$14 = None </ins> // gdb-command: print nested_variant1 <del> // gdb-check:$13 = NestedVariant1 = {NestedStruct = {regular_struct = RegularStruct = {the_first_field = 111, the_second_field = 112.5, the_third_field = true, the_fourth_field = "NestedStructString1"}, tuple_struct = TupleStruct = {113.5, 114}, empty_struct = EmptyStruct, c_style_enum = CStyleEnumVar2, mixed_enum = MixedEnumTupleVar = {115, 116, false}}} </del> <ins> // gdb-check:$15 = NestedVariant1 = {NestedStruct = {regular_struct = RegularStruct = {the_first_field = 111, the_second_field = 112.5, the_third_field = true, the_fourth_field = "NestedStructString1"}, tuple_struct = TupleStruct = {113.5, 114}, empty_struct = EmptyStruct, c_style_enum = CStyleEnumVar2, mixed_enum = MixedEnumTupleVar = {115, 116, false}}} </ins> // gdb-command: print nested_variant2 <del> // gdb-check:$14 = NestedVariant2 = {abc = NestedStruct = {regular_struct = RegularStruct = {the_first_field = 117, the_second_field = 118.5, the_third_field = false, the_fourth_field = "NestedStructString10"}, tuple_struct = TupleStruct = {119.5, 120}, empty_struct = EmptyStruct, c_style_enum = CStyleEnumVar3, mixed_enum = MixedEnumStructVar = {field1 = 121.5, field2 = -122}}} </del> <ins> // gdb-check:$16 = NestedVariant2 = {abc = NestedStruct = {regular_struct = RegularStruct = {the_first_field = 117, the_second_field = 118.5, the_third_field = false, the_fourth_field = "NestedStructString10"}, tuple_struct = TupleStruct = {119.5, 120}, empty_struct = EmptyStruct, c_style_enum = CStyleEnumVar3, mixed_enum = MixedEnumStructVar = {field1 = 121.5, field2 = -122}}} </ins> use self::CStyleEnum::{CStyleEnumVar1, CStyleEnumVar2, CStyleEnumVar3}; use self::MixedEnum::{MixedEnumCStyleVar, MixedEnumTupleVar, MixedEnumStructVar};

let some = Some(110u); let none: Option<int> = None; <ins> let some_fat = Some("abc"); let none_fat: Option<&'static str> = None; </ins> let nested_variant1 = NestedVariant1( NestedStruct {