[PATCH] Fix handling of discriminantless univariant enums in Rust

Tom Tromey tom@tromey.com
Mon Oct 31 03:03:00 GMT 2016


>>>>> "Manish" == Manish Goregaokar <manish@mozilla.com> writes:

Manish> +  else if (TYPE_NFIELDS (type) == 1) {
Manish> +    /* Sometimes univariant enums are encoded without a
Manish> +    discriminant. In that case, treating it as an encoded enum
Manish> +    with the first field being the actual type works.  */
Manish> +    const char* field_name = TYPE_NAME (TYPE_FIELD_TYPE (type, 0));
Manish> +    ret.name = concat (TYPE_NAME (type), "::",
Manish> +                       rust_last_path_segment (field_name),
Manish> +                       (char *) NULL);
Manish> +    ret.field_no = RUST_ENCODED_ENUM_REAL;
Manish> +    ret.is_encoded = 1;
Manish> +    return ret;
Manish> +  }
Manish>    if (strcmp (TYPE_FIELD_NAME (disr_type, 0), "RUST$ENUM$DISR") != 0)

This still should follow GNU style.
And I think a blank line after the "}".

Manish> +gdb_test "print parametrized.next.val" " =
Manish> \\(simple::ParametrizedStruct<i32> \\*\\) $hex"

Patch mangled by mail program.
No biggie but it's a pain if one wants to try it out.

Manish> $hex\\}, value: 0\\}"
Manish> \ No newline at end of file

Please add a newline.

Tom



More information about the Gdb-patches mailing list